Linuxbrew / brew

:beer::penguin: The Homebrew package manager for Linux
https://linuxbrew.sh
BSD 2-Clause "Simplified" License
2.66k stars 237 forks source link

brew audit results in error, while installing rubocop #731

Closed bukzor closed 6 years ago

bukzor commented 6 years ago

To help us debug your issue please explain:

sjackman commented 6 years ago

Are you able to reproduce this issue in a Docker image, particularly linuxbrew/linuxbrew? It'll make it easier to troubleshoot if you can.

bukzor commented 6 years ago

If I mount nothing to the image, brew audit works as expected. If I mount my local brew prefix, I get a different error:

$ docker run -v $HOME/prefix/brew:/home/linuxbrew/.linuxbrew -ti linuxbrew/linuxbrew brew audit --strict jdk
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.3.3_2.x86_64_linux.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.3.3_2.x86_64_linux.bottle.tar.gz
==> Installing or updating 'rubocop' gem
Successfully installed rubocop-0.55.0
1 gem installed
Error: cannot load such file -- parser
Please report this bug:
  https://github.com/Linuxbrew/brew/wiki/troubleshooting
/home/linuxbrew/.linuxbrew/Library/Homebrew/vendor/portable-ruby/2.3.3_2/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/linuxbrew/.linuxbrew/Library/Homebrew/vendor/portable-ruby/2.3.3_2/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/linuxbrew/.linuxbrew/Library/Homebrew/vendor/bundle/ruby/2.3.0/gems/rubocop-0.55.0/lib/rubocop.rb:3:in `<top (required)>'
/home/linuxbrew/.linuxbrew/Library/Homebrew/vendor/portable-ruby/2.3.3_2/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
/home/linuxbrew/.linuxbrew/Library/Homebrew/vendor/portable-ruby/2.3.3_2/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
/home/linuxbrew/.linuxbrew/Library/Homebrew/vendor/portable-ruby/2.3.3_2/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
/home/linuxbrew/.linuxbrew/Library/Homebrew/style.rb:21:in `check_style_impl'
/home/linuxbrew/.linuxbrew/Library/Homebrew/style.rb:14:in `check_style_json'
/home/linuxbrew/.linuxbrew/Library/Homebrew/dev-cmd/audit.rb:119:in `audit'
/home/linuxbrew/.linuxbrew/Library/Homebrew/brew.rb:99:in `<main>'

The biggest difference seems to be the use of bottled ruby, but if I install ruby via apt, there's no real difference:

$ docker run -v $HOME/prefix/brew:/home/linuxbrew/.linuxbrew -ti linuxbrew/linuxbrew sh -c 'sudo apt update &&sudo apt install ruby && brew audit --strict jdk'

The strange thing is that it still insists on downloading a bottled ruby, although not so on my host system.

bukzor commented 6 years ago

Back on the host system, the use of bottled ruby changes my error message:

$ brew -v audit -vd --strict jdk
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/binutils.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/make.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/jdk.rb
Error: No such file or directory - rubocop
/home/buck/prefix/brew/Library/Homebrew/vendor/portable-ruby/2.3.3_2/lib/ruby/2.3.0/open3.rb:199:in `spawn'
/home/buck/prefix/brew/Library/Homebrew/vendor/portable-ruby/2.3.3_2/lib/ruby/2.3.0/open3.rb:199:in `popen_run'
/home/buck/prefix/brew/Library/Homebrew/vendor/portable-ruby/2.3.3_2/lib/ruby/2.3.0/open3.rb:95:in `popen3'
/home/buck/prefix/brew/Library/Homebrew/vendor/portable-ruby/2.3.3_2/lib/ruby/2.3.0/open3.rb:258:in `capture3'
/home/buck/prefix/brew/Library/Homebrew/style.rb:91:in `check_style_impl'
/home/buck/prefix/brew/Library/Homebrew/style.rb:14:in `check_style_json'
/home/buck/prefix/brew/Library/Homebrew/dev-cmd/audit.rb:119:in `audit'
/home/buck/prefix/brew/Library/Homebrew/brew.rb:99:in `<main>'

If I blow away the gems (but leave bottled ruby intact) and try again, it works correctly.

$ rm -rf Library/Homebrew/vendor/bundle/ruby/2.3.0/

$ brew -v audit -vd --strict jdk                   
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/binutils.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/make.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/jdk.rb
==> Installing or updating 'rubocop' gem
Fetching: parallel-1.12.1.gem (100%)
Successfully installed parallel-1.12.1
Fetching: ast-2.4.0.gem (100%)
Successfully installed ast-2.4.0
Fetching: parser-2.5.1.0.gem (100%)
Successfully installed parser-2.5.1.0
Fetching: powerpack-0.1.2.gem (100%)
Successfully installed powerpack-0.1.2
Fetching: rainbow-3.0.0.gem (100%)
Successfully installed rainbow-3.0.0
Fetching: ruby-progressbar-1.9.0.gem (100%)
Successfully installed ruby-progressbar-1.9.0
Fetching: unicode-display_width-1.4.0.gem (100%)
Successfully installed unicode-display_width-1.4.0
Fetching: rubocop-0.55.0.gem (100%)
Successfully installed rubocop-0.55.0
8 gems installed
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/jdk@8.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/jdk@7.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/curl.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/openssl.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/pkg-config.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaContentsLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/jdk.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaContentsLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/jdk.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaContentsLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/jdk.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaContentsLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/jdk.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaContentsLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/jdk.rb
/home/buck/prefix/brew/Library/Homebrew/brew.rb (Formulary::FormulaContentsLoader): loading /home/buck/prefix/brew/Library/Taps/homebrew/homebrew-core/Formula/jdk.rb
jdk:
  * C: 2: col 62: Description shouldn't end with a full stop
  * C: 8: col 6: Don't use OS.linux?; Homebrew/core only supports macOS
  * C: 11: col 9: Don't use OS.mac?; Homebrew/core only supports macOS
  * C: 21: col 54: Don't use OS.mac?; Homebrew/core only supports macOS
  * C: 26: col 1: Use 2 spaces for indentation in a heredoc.
Error: 5 problems in 1 formula

I don't really know anything about ruby or gems, so I can't provide any insight or creative debugging.

bukzor commented 6 years ago

Ah, I expect this has something to do with it:

$ echo $GEM_HOME 
/home/buck/prefix/rubygems
bukzor commented 6 years ago

I tried a whole bunch of variations of:

but it won't reproduce the problem in the docker image. It doesn't seem to ever use $GEM_HOME, nor /usr/bin/ruby.

sjackman commented 6 years ago

I'm afraid that I'm not terribly knowledgable of troubleshooting Ruby gems either. Sorry that I can't be of more help.

bukzor commented 6 years ago

Since I can't reproduce it, and I've found a workaround, let's close this and reopen if it re-emerges.