Don’t rely on having external commands always present in the PATH in
order to find them. Instead, provide an accessory method to Tap so
they can be added and used when needed.
While we’re here, do some general refactoring and cleanup of the
command code in these places.
- If a non-existent command with a flag is queried to Cask, the latter
is printed instead of the command
- If the help from a not-yet-tapped cask's command is queried, it
prints brew tap's help infinitely
Fixescaskroom/homebrew-cask#28977
- `brew.rb` needed updated to fail unless on Ruby 2.3
- `brew update` should unset `HOMEBREW_RUBY_PATH` to ensure that this
doesn't "stick" on a Ruby 2.0 version after a portable Ruby has been
installed.
The `brew test` tests were failing as they were unable to include
`test/unit/assertions`. This is because it's a gem and we were setting
the `GEM_HOME` so system gems were being ignored.
While I was there and examining the `$LOAD_PATH`: reduce the number of
things we add there by using `Bundler.with_clean_env` and only adding
`HOMEBREW_LIBRARY_PATH` in the `$LOAD_PATH` if it isn't already there
(which it always is [and has to be] for integration tests).
This also seems to have the side effect of speeding up integration
tests from 1m26s to 1m8s on my machine.
If people have `HOMEBREW_RUBY_PATH` set then things explode in a rather
confusing fashion. Instead, run `bundle` for them with the arguments
that they'd want.
Also, move `macho` requires into the module itself; it's a pain having
to do everything for Bundler before requiring `pathname` which is a core
Ruby class.
Homebrew's actually ended up using a fair few gems. While we want to
avoid Bundler at runtime (and this PR still does that, in fact uses
Bundler even less at runtime than it did before) writing our own version
to use at build-time seems redundant.
For tagged commits produces the output:
- `1.0.1`
For untagged commits with a dirty tree produces the output:
- `1.0.1-19-g23efbc5-dirty`
Performance:
```
git describe --tags --dirty 2> /dev/null
0.07s user 0.01s system 96% cpu 0.086 total
```
This means we can tag any commit without needing to manually remember
to bump the revision every time.