18 Commits

Author SHA1 Message Date
rmnull
a7405601f3
Use Gem to install gems instead of invoking system 2020-06-04 11:36:58 +05:30
Mike McQuaid
b615de1bc3
utils/gems: always ensure default Gems are in GEM_PATH.
Fixes #7608.
2020-06-03 10:02:46 +01:00
Mike McQuaid
73df5891ef
Merge pull request #7283 from claui/fix-make-tmpfile
Ensure TMPDIR is set for Xcode’s `make`
2020-04-11 13:11:30 +01:00
Claudia
29538c89cd
Set TMPDIR for Xcode’s make
This fixes an issue where at least in Xcode 11.0, `make` uses
`/var/tmp` as a fallback for temporary files unless `TMPDIR` is set:

```
$ strings "$(xcrun -f make)" | grep -B 3 fopen
TMPDIR
/var/tmp/
GmXXXXXX
fopen (temporary file)
```

Given that Homebrew filtered `TMPDIR`, and the `/var/tmp` directory may
not be writable for non-root users, this would cause Homebrew’s
build environment to error out:

```
$ brew ruby -e 'puts ENV["TMPDIR"]; puts `: | make -f -`'
```

```
Ignoring bigdecimal-2.0.0 because its extensions are not built. Try: gem pristine bigdecimal --version 2.0.0
[…]
Ignoring zlib-1.1.0 because its extensions are not built. Try: gem pristine zlib --version 1.1.0
make: *** fopen (temporary file): Permission denied.  Stop.
```

In practice, this would break `brew audit`, `brew style`, and other
commands, which would run `make` to build native gem extensions.

This commit sets `TMPDIR` to `${HOMEBREW_TEMP}` in the gem environment, which
mirrors the behaviour we already have in other places.
We choose `HOMEBREW_TEMP` because that’s user-controlled but also falls
back to `/tmp` in case `TMPDIR` is not set in the user’s environment.

Thanks to Bo Anderson for helping find the bug.

CC: Bo Anderson <mail@boanderson.me>
2020-04-11 08:01:05 +02:00
Bo Anderson
846166c62f utils/gems: prioritise Homebrew's chosen Ruby 2020-04-05 15:38:10 +01:00
Mike McQuaid
682ac2a3b8
utils/gems: hardcode bundler version.
This should avoid issues like those described in:
https://discourse.brew.sh/t/bump-pr-formula-bundler-version/6520/3
2020-01-01 15:47:06 +00:00
Mike McQuaid
3609101728
utils/gems: fix finding bundler.
Need to specify the executable name not variable here.
2019-11-01 17:04:27 +00:00
Mike McQuaid
77531166d6
Use bundler from Ruby 2.6
Now Ruby comes with its own bundler let's favour using it when we can
over requiring a system one be installed.

This avoids needing to have anything in `~/.gem` again.

I am somewhat optimistic this may help with #6579 but it's useful
by itself.
2019-10-30 13:49:17 +00:00
Markus Reiter
a49282c318 Simplify return value logic. 2019-10-04 23:39:26 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +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
EricFromCanada
89f0fcedbe whitespace fixes 2019-04-13 21:32:04 -04:00
EricFromCanada
fa6404e0f5 grammar fixes 2019-04-13 21:29:32 -04:00
Mike McQuaid
128300a754
utils/gems: install Bundler 2.
Our Gemfile requires it and it will result in a more consistent configuration.
2019-02-28 12:29:52 +00:00
Mike McQuaid
17f3ee1957
Improve Bundler cleanup
Rather than trying to be smart and doing this ourselves in `brew cleanup` let’s just installed Bundler somewhere it doesn’t try to clean itself up and use `bundle install --cleanup` when we need cleanup done.

Also, use `ohai` and `odie` when possible as they look nicer.
2019-02-27 14:02:46 +00:00
Mike McQuaid
3a2259c271
utils/gems: silence bundle check output. 2019-02-21 16:34:20 +00:00
Mike McQuaid
6b326f4465
Move all gems to vendor/bundle, remove vendor/bundle-standlone. 2019-02-21 16:34:20 +00:00
Mike McQuaid
4f76d12874
utils/gems: extract from utils.
Also, don’t use any non-standard Ruby functionality to avoid needing any `requires.
2019-02-21 12:56:22 +00:00