63 Commits
Author SHA1 Message Date
Bo Anderson c6ca375d5a utils/ruby.sh: fix error with older Bash
Fixes #12472.
2021-12-02 02:14:11 +00:00
Bo Anderson d0f6f7d52b Require Ruby 2.6.8 2021-11-08 18:39:21 +00:00
XuehaiPan c2d5d84b21 Merge remote-tracking branch 'upstream/master' into fix-inconsistent-shell-style 2021-09-16 01:01:49 +08:00
XuehaiPan 3f96d963f7 style: fix inconsistent code style for shell scripts 2021-09-15 14:59:01 +08:00
XuehaiPan d77d510ce9 brew.sh: alias which as type -P 2021-09-15 02:18:27 +08:00
XuehaiPan 5c6d2b154f utils/ruby.sh: remove dependency for which command 2021-09-11 15:02:04 +08:00
Bo Anderson d15cb8a83d utils/ruby.sh: fix Ruby path searching 2021-05-05 22:59:24 +01:00
hyuraku 2b6afea8ed utils/ruby.sh: repair style 2021-04-21 22:19:35 +09:00
EricFromCanada 6fc116318e fixes for grammar and wording 2021-01-26 16:19:47 -05:00
Seeker 78a02e03a9 utils/ruby: silence which errors when finding ruby 2020-12-15 16:25:50 -08:00
Maxim Belkin 15dbb0be58 utils/ruby.sh: simplify and fix Ruby-related logic
General:
- Rename `unusable_ruby` to `need_vendored_ruby` (due to code changes).

**`setup-ruby-path`** function:
- Move `-z "$HOMEBREW_RUBY_PATH"` and `-n "$HOMEBREW_FORCE_VENDOR_RUBY"` checks to `need_vendored_ruby`.

**`need_vendored_ruby`** function:
- Check `HOMEBREW_FORCE_VENDOR_RUBY` first so that it's respected even
  on Macs that are "new enough" (`HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH` is set).
- Don't check `-n $HOMEBREW_RUBY_PATH` because it is implicitly tested
  by `test_ruby`.
- Remove (now-) redundant `-z $HOMEBREW_FORCE_VENDOR_RUBY` check as it is
  tested earlier in the conditional.
2020-12-08 18:05:28 -06:00
Mike McQuaid f7d72ae77c ruby.sh: don't test ruby on macOS.
Instead defer to the `HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH`
variable.
2020-12-08 17:23:06 +00:00
Maxim BelkinandMike McQuaid a6d29894d9 cleanup: fix and reuse portable ruby logic.
Align the logic in `cleanup_portable_ruby` with that in `ruby.sh`.

Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2020-09-03 09:43:41 +01:00
Maxim BelkinandMike McQuaid cfbc09f3c1 utils/ruby.sh: move 'advice' var to Linux.
Also change 'usable_ruby()' to 'unusable_ruby()'

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2020-08-14 12:37:10 +00:00
Maxim Belkin 50f47e88ec utils/ruby.sh: reoganize code
Moved OS-specific logic to functions:
 - `find_ruby`: returns (via echo) Ruby that can be used
 - `usable_ruby`: checks whether Ruby satisfies Homebrew

Pre-create OS-specific error messages:
 - `upgrade_fail`: message that is printed when Homebrew fails to upgrade
   vendor Ruby
 - `install_fail`: message that is printed when Homebrew fails to install
   vendor Ruby

Unconditionally set `TERMINFO_DIRS` when installing/upgrading vendor Ruby
**but** export it on Linux only.

Motivation: move OS-specific logic to functions so that it's easier to
understand the main steps.
2020-08-13 23:57:23 +00:00
Maxim Belkin f3283b60cc utils/ruby.sh: test_ruby(): keep temporary variables local 2020-08-12 17:07:41 -05:00
Mike McQuaid 15a2abd9df style: re-enable shellcheck.
Ensure that `shellcheck` is run by `brew style` again and fix the
various failures.
2020-07-07 11:53:55 +01:00
Mike McQuaid 07ea18e2d2 ruby.sh: don't print recoverable error.
This prints "error" even when we can install a portable ruby.
2020-06-23 13:13:31 +01:00
Mike McQuaidandGitHub 854e96c7c5 Merge pull request #7686 from maxim-belkin/test_ruby_update
utils/ruby.sh: update `test-ruby` (and rename to test_ruby)
2020-06-12 09:13:15 +01:00
Bo Anderson 87931e1c03 utils/ruby.sh: set TERMINFO_DIRS to bundled terminfo 2020-06-10 14:36:18 +01:00
Maxim Belkin 23d24dfed7 utils/ruby.sh: rely on test_ruby's exit code
Instead of printing "true" or "false", test_ruby now returns 1 when
tested Ruby is not usable and 0 if it is.
2020-06-10 07:56:37 -05:00
9751d3bb8c Fix calls to 'test_ruby' in conditional statements
Co-authored-by: Shaun Jackman <sjackman@gmail.com>
2020-06-06 12:03:51 -05:00
Maxim Belkin 58f3e49c0b utils/ruby.sh: rename test-ruby to test_ruby. Cosmetic changes 2020-06-03 18:01:38 -05:00
Maxim Belkin 5d3456f485 utils/ruby.sh: make code more readable
1. Repurpose 'vendor_ruby_current_version' variable:
   now this is not a pointer to a file but actual version number
2. Introduce 'vendor_ruby_latest_version' variable:
   it holds the value of the latest version of portable Ruby
2020-05-21 17:15:14 -05:00
Maxim Belkin db561eb7b9 utils/ruby.sh: setup-ruby: handle 'vendor-install' cmd early
Exit from the 'setup-ruby' function when user issued
`vendor-install` command.
We do so instead of wrapping everything in

```sh
if [[ "$HOMEBREW_COMMAND" != "vendor-install" ]]
```

`git diff` when whitespaces are ignored:

$ git diff -w
diff --git a/Library/Homebrew/utils/ruby.sh b/Library/Homebrew/utils/ruby.sh
index 7974e909c..4be204309 100644
--- a/Library/Homebrew/utils/ruby.sh
+++ b/Library/Homebrew/utils/ruby.sh
@@ -27,8 +27,11 @@ If there's no Homebrew Portable Ruby available for your processor:

   unset HOMEBREW_RUBY_PATH

-  if [[ "$HOMEBREW_COMMAND" != "vendor-install" ]]
+  if [[ "$HOMEBREW_COMMAND" == "vendor-install" ]]
   then
+    return 0
+  fi
+
   if [[ -x "$vendor_ruby_path" ]]
   then
     HOMEBREW_RUBY_PATH="$vendor_ruby_path"
@@ -85,7 +88,6 @@ If there's no Homebrew Portable Ruby available for your processor:
       HOMEBREW_RUBY_PATH="$vendor_ruby_path"
     fi
   fi
-  fi

   export HOMEBREW_RUBY_PATH
 }
2020-05-21 15:06:21 -05:00
Maxim Belkin 8dcb1636ce utils/ruby.sh: add explanatory comments 2020-05-20 12:29:45 -05:00
Maxim Belkin dcc486fa9e utils/ruby.sh: find usable Ruby from PATH only 2020-05-19 12:24:00 -05:00
Maxim Belkin b4267d80e4 utils/ruby.sh: avoid nested ifs 2020-05-17 16:32:06 -05:00
Maxim Belkin 083f56fafe utils/ruby.sh: quote HOMEBREW_RUBY_PATH when calling test-ruby 2020-05-15 16:35:42 -05:00
Maxim Belkin f7e0705164 utils/ruby.sh: try installing portable Ruby ...
when no usable Ruby is found.
2020-05-15 15:12:20 -05:00
Maxim Belkin 44ef1abd1f utils/ruby.sh: suppress standard error in test-ruby 2020-05-15 15:04:06 -05:00
Maxim Belkin ec6e449f4f utils/ruby.sh: unset HOMEBREW_RUBY_PATH unconditionally 2020-05-15 14:21:51 -05:00
Maxim Belkin d21ecffae6 utils/ruby.sh: break down long ruby code in test-ruby 2020-05-15 14:20:03 -05:00
cbc266bf0e utils/ruby.sh: split long line in test-ruby() function
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2020-05-15 13:49:22 -05:00
Maxim Belkin 328c75fc33 Move logic related to HOMEBREW_RUBY_PATH to utils/ruby.sh 2020-05-15 10:30:45 -05:00
Mike McQuaid 6123cdb767 Improve Homebrew Portable Ruby messaging
As-of https://github.com/Homebrew/homebrew-portable-ruby/pull/100 we've
removed ARM builds for Portable Ruby due to months of breakage.
Similarly, when we last bumped Portable Ruby the ARM build was much
delayed but, despite Homebrew/brew being completely unusable to anyone
using it on ARM in that case, no-one complained or filed issues.

Instead of attempting to maintain and update a Portable Ruby on niche
(Homebrew) platforms like ARM (or, in past/future PPC) improve the
messaging to provide users with a workaround.

Now we allow only a major/minor version match it should be pretty
doable for those users to install e.g. a prebuilt Ruby binary from a PPA
or built it from source if needed using `ruby-build` and `rbenv`.

The messaging could be improved further but we're somewhat limited by
`ruby.sh` and `vendor-install.sh` being separate. I'm tempted to combine
them (or at least have `vendor-install.sh` not be so generic as to not
be able to give Ruby-specific advice).
2020-05-02 13:53:45 +01:00
Eric Knibbe fa1ce146e4 ruby.sh: allow running on older ruby versions 2020-04-22 17:36:00 -04:00
Mike McQuaid 8471421c86 utils/ruby.sh: fix macOS portable Ruby detection.
Avoid unconditionally installing due to a variable name change.
2020-02-01 19:10:17 +01:00
Mike McQuaid 0b09c07862 ruby.sh: fix whitespace and tweak required ruby version check. 2020-02-01 12:49:35 +01:00
cad7f98527 Clean up variable names
Co-Authored-By: Mike McQuaid <mike@mikemcquaid.com>
2020-01-31 15:17:32 -08:00
emreerhan a1102f253c Remove checks to variable that is not set anywhere 2020-01-30 15:48:41 -08:00
emreerhan 027cc68534 Add condition to check if ruby version is < 2.7 2020-01-30 15:01:26 -08:00
Mike McQuaid e9aba2efb6 Require and provide portable Ruby 2.6.3. 2019-10-10 15:53:16 +01:00
Mike McQuaid 86f43f79ee Enable/fix optional Ruby frozen string literal usage
Combined with https://github.com/Homebrew/homebrew-test-bot/pull/247
this will test Homebrew's use of frozen strings in CI. After this we
will then enable it for Homebrew developers and eventually all Homebrew
users.
2019-04-19 10:30:41 +09:00
Mike McQuaid 9e7b98d3e2 Don't check system Ruby is new enough when unnecessary.
We know this is the case in macOS >=10.13.3 so save a Ruby process call.
2019-04-18 21:42:28 +09:00
Mike McQuaid ef2e297d3b Disable RubyGems by default.
This speeds up all Ruby invocations where we don't need RubyGems by
around 10%. Where we do need RubyGems: include it manually.
2019-04-18 17:45:03 +09:00
Mike McQuaid d33c225e47 utils/ruby: don't remove cleanup bundler.
We're sharing this directory now.
2019-02-22 15:59:14 +00:00
Mike McQuaid a11fe57cd2 cache_store: handle corrupt DBM database.
When the DBM database cannot be read by the current version of Ruby's
DBM library (due to corruption or another incompatibility) it segfaults
or freezes which takes down the entire Homebrew Ruby process.

This isn't desirable so instead perform a shell out with the Homebrew
Ruby to see if it can read the DBM database before we try to use the
information. If this hangs or crashes: silently delete the database and
recreate it.
2018-09-20 10:57:27 +01:00
Mike McQuaid f2d823445e ruby.sh: remove linkage cache on upgrade.
This may not be compatible between portable ruby versions and between
portable and system ruby versions.

Fixes #4485.
2018-07-18 14:09:43 +01:00
Mike McQuaid 9b86ff6214 ruby.sh: cleanup gems on portable Ruby installation.
This avoids `brew style` and friends from getting upset when they
attempt to use the native gem extensions from a previous portable Ruby
or a system Ruby.

ABI? What's that?
2018-07-13 14:37:12 +01:00