- do some optimisation of `require`s before Bootsnap
- remove `HOMEBREW_BOOTSTRAP` environment variable as it's set by
default
- add fast require in `bootsnap.rb` using logic from `ruby.sh`
- cleanup `bootsnap.rb` a bit
- remove setting `HOMEBREW_BOOTSNAP` in GitHub Actions
- Use the `HOMEBREW_PORTABLE_RUBY_VERSION` environment variable to
determine the version of the Portable Ruby to use in
`vendor-install.sh` and `ruby.sh`.
- Replace the `docs/.ruby-version` file with a symlink to
`Library/Homebrew/.ruby-version`.
- Fix an incorrect `HOMEBREW_LIBRARY` comment.
- Use a simpler `HOMEBREW_USING_PORTABLE_RUBY` definition.
This avoids can avoid UID/EUID related issues with Ruby scripts passed
over `stdin` clashing with Ruby security features.
It's also just a bit nicer to have Ruby scripts in files instead.
While we're here:
- refactor some shared logic into a new `setup-gem-home-bundle-gemfile`
function in `ruby.sh`
- do some general cleanup of `lock.sh`
- prioritise `flock` over `python` in `lock.sh`
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.
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>
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.
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
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
}