rubymem / bundler-leak

Known-leaky gems verification for bundler: `bundle leak` to check your app and find leaky gems in your Gemfile :gem::droplet:
https://www.rubymem.com
GNU General Public License v3.0
288 stars 11 forks source link

[BUG] Test suite is currently broken #46

Closed etagwerker closed 2 years ago

etagwerker commented 2 years ago

Before we start...:

Branch/Commit:

main

Expected behavior:

Test suite should pass.

Actual behavior:

Test suite does not pass.

Steps to reproduce:

  1. git clone repo
  2. bundle install with ruby 2.7 (or 2.6) -- version doesn't matter that much
  3. bundle exec rake

Context and environment:

You can see this failure in GitHub Actions. It should be easy to replicate in a Mac OS X environment too (I did!)

Part of the problem is that every time we run the test suite we are creating a brand new Gemfile.lock inside the unpatched_gems directory: https://github.com/rubymem/bundler-leak/blob/main/Rakefile#L43-L47

I don't see why that is necessary, that particular Gemfile.lock could be checked in to the repository. The important part is to have the unpatched gem inside the Gemfile.lock file.

Logs

bundle exec rake
cd spec/bundle/unpatched_gems
unset BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT && bundle config set --local path '../../../vendor/bundle' && bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using bundler 2.1.4
Using dotenv 2.7.6
Using nenv 0.3.0
Using rspec-logsplit 0.1.3
Using hitimes 2.0.0
Using libv8 3.16.14.19
Using ref 2.0.0
Using timers 4.0.4
Fetching therubyracer 0.12.1
Using celluloid-essentials 0.20.2
Using celluloid-extras 0.20.0
Using celluloid-fsm 0.20.0
Using celluloid-pool 0.20.0
Using celluloid-supervision 0.20.1
Using celluloid 0.17.0
Installing therubyracer 0.12.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/etagwerker/Projects/rubymem/bundler-leak/vendor/bundle/ruby/2.7.0/gems/therubyracer-0.12.1/ext/v8
/Users/etagwerker/.rvm/rubies/ruby-2.7.3/bin/ruby -I /Users/etagwerker/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0 -r ./siteconf20220315-10483-1353tzy.rb extconf.rb --with-v8-dir\=/usr/local/opt/v8
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/etagwerker/.rvm/rubies/ruby-2.7.3/bin/$(RUBY_BASE_NAME)
    --with-pthread-dir
    --without-pthread-dir
    --with-pthread-include
    --without-pthread-include=${pthread-dir}/include
    --with-pthread-lib
    --without-pthread-lib=${pthread-dir}/lib
    --with-pthreadlib
    --without-pthreadlib
    --with-objc-dir
    --without-objc-dir
    --with-objc-include
    --without-objc-include=${objc-dir}/include
    --with-objc-lib
    --without-objc-lib=${objc-dir}/lib
    --with-objclib
    --without-objclib
    --enable-debug
    --disable-debug
    --with-v8-dir
    --with-v8-include
    --without-v8-include=${v8-dir}/include
    --with-v8-lib
    --without-v8-lib=${v8-dir}/lib
/Users/etagwerker/Projects/rubymem/bundler-leak/vendor/bundle/ruby/2.7.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.

However, your system version of v8 could not be located.

Please make sure your system version of v8 that is compatible
with 3.16.14.19 installed. You may need to use the
--with-v8-dir option if it is installed in a non-standard location
    from /Users/etagwerker/Projects/rubymem/bundler-leak/vendor/bundle/ruby/2.7.0/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
    from extconf.rb:32:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/etagwerker/Projects/rubymem/bundler-leak/vendor/bundle/ruby/2.7.0/extensions/x86_64-darwin-19/2.7.0/therubyracer-0.12.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/etagwerker/Projects/rubymem/bundler-leak/vendor/bundle/ruby/2.7.0/gems/therubyracer-0.12.1 for inspection.
Results logged to /Users/etagwerker/Projects/rubymem/bundler-leak/vendor/bundle/ruby/2.7.0/extensions/x86_64-darwin-19/2.7.0/therubyracer-0.12.1/gem_make.out

An error occurred while installing therubyracer (0.12.1), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.12.1' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  therubyracer
rake aborted!
Command failed with status (5): [unset BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYO...]
/Users/etagwerker/Projects/rubymem/bundler-leak/Rakefile:45:in `block (4 levels) in <top (required)>'
/Users/etagwerker/Projects/rubymem/bundler-leak/Rakefile:44:in `block (3 levels) in <top (required)>'
/Users/etagwerker/Projects/rubymem/bundler-leak/Rakefile:43:in `each'
/Users/etagwerker/Projects/rubymem/bundler-leak/Rakefile:43:in `block (2 levels) in <top (required)>'
/Users/etagwerker/.rvm/rubies/ruby-2.7.3/bin/bundle:23:in `load'
/Users/etagwerker/.rvm/rubies/ruby-2.7.3/bin/bundle:23:in `<main>'
/Users/etagwerker/.rvm/gems/ruby-2.7.3@leak/bin/ruby_executable_hooks:22:in `eval'
/Users/etagwerker/.rvm/gems/ruby-2.7.3@leak/bin/ruby_executable_hooks:22:in `<main>'
Tasks: TOP => default => spec => spec:bundle
(See full trace by running task with --trace)

I will abide by the code of conduct

bronzdoc commented 2 years ago

@etagwerker We can add the Gemfile.lock 👍 I see rubysec added it too https://github.com/rubysec/bundler-audit/tree/master/spec/bundle/unpatched_gems I don't know if that would solve the Gem::Ext::BuildError: ERROR: Failed to build gem native extension. error though

etagwerker commented 2 years ago

@bronzdoc Sounds good. I went ahead and did that in my local environment and it seems to work fine. I'll push my changes to #45 as soon as GitHub starts working again... 😄

bronzdoc commented 2 years ago

clsoed by https://github.com/rubymem/bundler-leak/pull/45