Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

bundler/inline fails to install missing gems if Gemfile exists in working dir #5117

Closed
mattbrictson opened this issue Oct 24, 2016 · 0 comments · Fixed by #5203
Closed

bundler/inline fails to install missing gems if Gemfile exists in working dir #5117

mattbrictson opened this issue Oct 24, 2016 · 0 comments · Fixed by #5203

Comments

@mattbrictson
Copy link
Contributor

If I am in directory that contains Gemfile and Gemfile.lock, running a bundler/inline script does not work as I expect.

Expected behavior

Any missing gems in the inline gem declaration will be installed.

Actual behavior

Bundler::GemNotFound is raised.

Tested with

Bundler 1.13.6
Ruby 2.3.1
RubyGems 2.6.7


$ cat Gemfile
source "https://rubygems.org"
gem "rake"

$ cat test.rb
#!/usr/bin/env ruby
require "bundler/inline"
gemfile do
  source "https://rubygems.org"
  gem "whirly"
end
puts "Done"

$ bundle install
$ ruby test.rb
/Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/resolver.rb:366:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'whirly' in any of the gem sources listed in your Gemfile or available on this machine. (Bundler::GemNotFound)
    from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/resolver.rb:341:in `each'
    from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/resolver.rb:341:in `verify_gemfile_dependencies_are_found!'
    from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/resolver.rb:199:in `start'
    from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/resolver.rb:181:in `resolve'
    from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/definition.rb:250:in `resolve'
    from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/definition.rb:174:in `specs'
    from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/installer.rb:171:in `ensure_specs_are_compatible!'
    from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/installer.rb:79:in `run'
    from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/installer.rb:24:in `install'
    from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/inline.rb:63:in `gemfile'
    from test.rb:3:in `<main>'

Removing the lock file from the working directory fixes the problem:

$ rm Gemfile.lock
$ ruby test.rb
Done
bundlerbot added a commit that referenced this issue Nov 25, 2016
…iddins

Dont build defintion with Gemfile.lock (if present) when resolving gems via inline gemfile

This fixes #5117

I am passing an option to `Installer` to not build a definition when resolving gems via inline gemfile.

Also, i notice: `Bundler.default_lockfile.exist? && !options["update"]...`. Is "update" suppose to be a string? I ask because i noticed that other options are being passed as symbols, so I'm not which i'm suppose to be using.

Thanks.

PS. Hopefully i have the bundler terminology correct 😄
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants