Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.32k stars 9.72k forks source link

Old ~/.gem folder breaks brew audit after OS upgrade #3355

Closed scpeters closed 7 years ago

scpeters commented 7 years ago

tl;dr I had a problem, found a solution, posting the solution here. Maintainers may close this issue if they don't think there's anything else to do.

Please always follow these steps:

$ brew config
HOMEBREW_VERSION: 1.3.6-37-g357b7bb
ORIGIN: https://github.com/Homebrew/brew
HEAD: 357b7bb0b72f5f3e2747ffffdad76d694f73b626
Last commit: 22 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: b7d1e926e9f2e3e950866b7e82ad1fbe34f1fb12
Core tap last commit: 5 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: quad-core 64-bit haswell
Homebrew Ruby: 2.3.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 9.0 build 900
Git: 2.13.5 => /Library/Developer/CommandLineTools/usr/bin/git
Perl: /usr/bin/perl
Python: /usr/local/opt/python/libexec/bin/python => /usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Java: 1.8.0_131
macOS: 10.13-x86_64
Xcode: N/A
CLT: 9.0.1.0.1.1506734476
X11: 2.7.11 => /opt/X11
$ brew doctor
Your system is ready to brew.

I was trying to audit a formula (ie. brew audit boost).

This normally works of course, and and it works on one of my 3 CI machines, but 2 of 3 were failing to find the rainbow gem when invoking brew audit directly (brew test-bot doesn't have this problem):

$ brew audit boost
Error: Could not find 'rainbow' (< 3.0, >= 2.2.2) among 26 total gem(s)
Checked in 'GEM_PATH=/Users/jenkins/.gem/ruby/2.3.0:/Library/Ruby/Gems/2.3.0:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0', execute `gem env` for more information
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/specification.rb:1439:in `block in activate_dependencies'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/specification.rb:1428:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/specification.rb:1428:in `activate_dependencies'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/specification.rb:1410:in `activate'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems.rb:196:in `rescue in try_activate'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems.rb:193:in `try_activate'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:125:in `rescue in require'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
/usr/local/Homebrew/Library/Homebrew/cmd/style.rb:74:in `check_style_impl'
/usr/local/Homebrew/Library/Homebrew/cmd/style.rb:67:in `check_style_json'
/usr/local/Homebrew/Library/Homebrew/dev-cmd/audit.rb:102:in `audit'
/usr/local/Homebrew/Library/Homebrew/brew.rb:99:in `<main>'

I realized that the two machines experiencing this problem had recently had OS upgrades (to 10.12 and 10.13). Our 10.11 machine hasn't had a major OS upgrade and still works fine. Renaming the ~/.gem folder to ~/.gem_old fixed the problem for me. Deleting it is an option as well, but it is at your own risk. I may also have a problem with environment variables I suppose.

I searched for this error message and wasn't able to find anyone else who had this problem. I was expecting an issue like this to exist so people could see the problem and a possible solution. I suppose a brew doctor complaint could be helpful as well or a raise message saying that the ~/.gem folder may be out of date if the OS is upgraded.

I haven't tried reproducing this since I figured out the solution, so I don't know if it will still happen or if it was a transient issue from when I upgraded my machines (in the month before High Sierra was released). You can close the issue if you don't want to take further action, but I can help debug this further or work on a pull request to document the issue, as I still have the old ~/.gem folder on one of my CI machines.

MikeMcQuaid commented 7 years ago

Closing this for now but will investigate further if it crops up more. CC @reitermarkus this may be another argument for using bundler for more of this stuff.

scpeters commented 6 years ago

I just had this gem issue pop again on a system running 10.11, though it wasn't after an OS upgrade. It initially was failing only with test-bot during bottle builds, though it didn't fail from direct calls of brew audit or brew style. On an impulse, I deleted the ~/.gem folder, and then it failed with manual calls to brew audit and brew style. I managed to fix it by running brew tests.

Here's some of the console error messages I was seeing (though it's now fixed).

==> brew audit osrf/simulation/ignition-fuel-tools1 --online
==> FAILED
Error: Could not find 'parallel' (~> 1.10) among 15 total gem(s)
Checked in 'GEM_PATH=/Users/jenkins/workspace/generic-release-homebrew_bottle_builder-elcapitan/home/.gem/ruby/2.3.0:/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/gems/2.3.0:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.3.0', execute `gem env` for more information
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/specification.rb:1439:in `block in activate_dependencies'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/specification.rb:1428:in `each'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/specification.rb:1428:in `activate_dependencies'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/specification.rb:1410:in `activate'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems.rb:196:in `rescue in try_activate'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems.rb:193:in `try_activate'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:125:in `rescue in require'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
/usr/local/Homebrew/Library/Homebrew/cmd/style.rb:74:in `check_style_impl'
/usr/local/Homebrew/Library/Homebrew/cmd/style.rb:67:in `check_style_json'
/usr/local/Homebrew/Library/Homebrew/dev-cmd/audit.rb:103:in `audit'
/usr/local/Homebrew/Library/Homebrew/brew.rb:100:in `<main>'
$ brew doctor
Your system is ready to brew.
$ brew config
HOMEBREW_VERSION: 1.5.2-40-ga44b21b
ORIGIN: https://github.com/Homebrew/brew
HEAD: a44b21b2dfd229c10a0c748c4f06e8ab6520f898
Last commit: 3 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 8571096379e0c2507e22ccf5c9ecd4af44f2ffe9
Core tap last commit: 41 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEV_CMD_RUN: 1
CPU: octa-core 64-bit ivybridge
Homebrew Ruby: 2.3.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: 8.0 build 800
Git: 2.10.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.43.0 => /usr/bin/curl
Perl: /usr/bin/perl
Python: /usr/local/opt/python/libexec/bin/python => /usr/local/Cellar/python/2.7.14_2/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: 1.8.0_131, 1.8.0_77
macOS: 10.11.6-x86_64
Xcode: 8.2.1
CLT: 8.2.0.0.1.1480973914
X11: 2.7.11 => /opt/X11

After deleting ~/.gem:

$ brew style libyaml
Error: Could not find 'parallel' (~> 1.10) among 15 total gem(s)
Checked in 'GEM_PATH=/Users/jenkins/.gem/ruby/2.3.0:/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/gems/2.3.0:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.3.0', execute `gem env` for more information
Please report this bug:
  https://docs.brew.sh/Troubleshooting.html
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/specification.rb:1439:in `block in activate_dependencies'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/specification.rb:1428:in `each'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/specification.rb:1428:in `activate_dependencies'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/specification.rb:1410:in `activate'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems.rb:196:in `rescue in try_activate'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems.rb:193:in `try_activate'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:125:in `rescue in require'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
/usr/local/Homebrew/Library/Homebrew/cmd/style.rb:74:in `check_style_impl'
/usr/local/Homebrew/Library/Homebrew/cmd/style.rb:61:in `check_style_and_print'
/usr/local/Homebrew/Library/Homebrew/cmd/style.rb:55:in `style'
/usr/local/Homebrew/Library/Homebrew/brew.rb:100:in `<main>'

but then brew tests got everything installed properly again.

ilovezfs commented 6 years ago

If removing ~/.gem doesn't work, then

rm -rf "$(brew --repo)"/Library/Homebrew/vendor
git -C "$(brew --repo)" checkout .

should work.