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

BUNDLE_GEMFILE="" breaks inline gemfiles #5079

Closed
smackesey opened this issue Oct 12, 2016 · 6 comments
Closed

BUNDLE_GEMFILE="" breaks inline gemfiles #5079

smackesey opened this issue Oct 12, 2016 · 6 comments
Assignees

Comments

@smackesey
Copy link

Ruby version: 2.3.1
Bundler version: 1.13.3

On my machine, the below script throws a GemfileNotFound error.

#!/usr/bin/env ruby
require 'bundler/inline'

gemfile { true }

This also happens if I use gemfile { gem 'anygemhere' } instead.

Here is the backtrace:

/usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.3/lib/bundler/shared_helpers.rb:25:in default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound) from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.3/lib/bundler/shared_helpers.rb:30:indefault_lockfile'
from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.3/lib/bundler.rb:265:in default_lockfile' from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.3/lib/bundler/installer.rb:214:inresolve_if_need'
from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.3/lib/bundler/installer.rb:78:in run' from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.3/lib/bundler/installer.rb:24:ininstall'
from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.3/lib/bundler/inline.rb:63:in gemfile' from /Users/smackesey/stm/tmp/161012122643_ruby_fork.rb:4:in

'

@indirect
Copy link
Member

Can you provide more context? That definitely works for me. Here's an example of it working.


$ cat test.rb
#!/usr/bin/env ruby

require 'bundler/inline'
gemfile do
  gem "rake"
end
require "rake"
puts Rake

$ ruby test.rb
Rake

$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

$ bundle -v
Bundler version 1.13.3

@indirect
Copy link
Member

For the record, it also works when installing gems that aren't already installed:

$ cat test.rb
#!/usr/bin/env ruby

require 'bundler/inline'
gemfile do
  gem "rack-obama"
end
puts "done"

$ ruby test.rb
/Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/resolver.rb:366:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'rack-obama' in any of the gem sources listed in your Gemfile or available on this machine. (Bundler::GemNotFound)
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/resolver.rb:341:in `each'
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/resolver.rb:341:in `verify_gemfile_dependencies_are_found!'
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/resolver.rb:199:in `start'
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/resolver.rb:181:in `resolve'
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/definition.rb:250:in `resolve'
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/definition.rb:174:in `specs'
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/definition.rb:162:in `resolve_remotely!'
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/installer.rb:225:in `resolve_if_need'
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/installer.rb:78:in `run'
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/installer.rb:24:in `install'
        from /Users/andre/.gem/ruby/2.3.1/gems/bundler-1.13.3/lib/bundler/inline.rb:63:in `gemfile'
        from test.rb:4:in `<main>'

$ vim test.rb

$ cat test.rb
#!/usr/bin/env ruby

require 'bundler/inline'
gemfile do
  source "https://rubygems.org"
  gem "rack-obama"
end
puts "done"

$ ruby test.rb
done

@smackesey
Copy link
Author

I figured out the cause of the error message is having $BUNDLE_GEMFILE set to an empty string. If I unset BUNDLE_GEMFILE then bundler/inline works correctly. I find this behavior surprising because for other bundler commands, when $BUNDLE_GEMFILE is an empty string bundler will follow default behavior (i.e. finding Gemfile in current directory).

@coilysiren
Copy link
Contributor

coilysiren commented Oct 16, 2016

@smackesey can you create a new reproduction case with your $BUNDLE_GEMFILE addition?

@indirect
Copy link
Member

@segiddins how do you feel about making inline mode completely ignore BUNDLE_GEMFILE?

@segiddins
Copy link
Member

So instead of https://github.com/bundler/bundler/blob/master/lib/bundler/inline.rb#L42, just monkey-patch Bundler::SharedHelpers.gemfile?

@segiddins segiddins self-assigned this Jan 15, 2017
@segiddins segiddins changed the title calling gemfile after require 'bundler/inline' throws GemfileNotFound error BUNDLE_GEMFILE="" breaks inline gemfiles Jan 15, 2017
bundlerbot added a commit that referenced this issue Jan 17, 2017
…rect

[Inline] Support running when BUNDLE_GEMFILE=""

Closes #5079
segiddins pushed a commit that referenced this issue Jan 20, 2017
…rect

[Inline] Support running when BUNDLE_GEMFILE=""

Closes #5079

(cherry picked from commit 4be8559)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants