73 Commits

Author SHA1 Message Date
Bo Anderson
7a9f3eb800
utils/ruby.sh: don't _require_ 3.1 in HOMEBREW_RUBY3 mode 2023-11-21 15:03:22 +00:00
Bo Anderson
559336c771
Enable Ruby 3 for HOMEBREW_DEVELOPER 2023-11-20 20:04:18 +00:00
Bo Anderson
386fd0548a
Support system Ruby 3 on Linux 2023-11-07 19:27:30 +00:00
Bo Anderson
4ec450823c
Portable Ruby 3.1.4 (opt-in beta) 2023-10-27 15:58:43 +01:00
Bo Anderson
71f558229a
Test on Ruby 3.1 2023-09-29 04:46:16 +01:00
Bo Anderson
e2aae0fa63
Require Ruby 2.6.10 2023-04-12 13:15:34 +01:00
Bo Anderson
10304ef569
util/ruby.sh: fix HOMEBREW_USE_RUBY_FROM_PATH to use user's PATH 2022-08-31 15:52:10 +01:00
Bo Anderson
ef20a53b4c
utils/ruby.sh: fix HOMEBREW_USE_RUBY_FROM_PATH on non-latest macOS 2022-08-03 23:28:44 +01:00
Sean Molenaar
84b0cbf352
ruby.sh: fix if statement
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2022-07-06 14:29:29 +02:00
Sean Molenaar
93ed7646b0
utils: allow developers to differ in ruby minor versions 2022-06-26 16:27:16 +02:00
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 Belkin
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 Belkin
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 McQuaid
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
Maxim Belkin
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
Maxim Belkin
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
Emre Erhan
cad7f98527
Clean up variable names
Co-Authored-By: Mike McQuaid <mike@mikemcquaid.com>
2020-01-31 15:17:32 -08:00