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

Bundler.setup does not respect RUBYLIB env var #328

Closed
evgeny-myasishchev opened this issue May 14, 2010 · 10 comments
Closed

Bundler.setup does not respect RUBYLIB env var #328

evgeny-myasishchev opened this issue May 14, 2010 · 10 comments

Comments

@evgeny-myasishchev
Copy link

Platform: OSX Snow Leopard
Ruby: ruby 1.9.1p376 (2009-12-07 revision 26041)

Ruby is installed into ${HOME}/r3 folder. Both GEM_HOME and GEM_PATH points to ${HOME}/r3 folder.

Following code:
require 'rubygems'
require 'bundler'

Bundler.setup

Raises:
/Users/jenya/r3/gems/bundler-0.9.25/lib/bundler/resolver.rb:1:in require': no such file to load -- set (LoadError) from /Users/jenya/r3/gems/bundler-0.9.25/lib/bundler/resolver.rb:1:in<top (required)>'
from /Users/jenya/r3/gems/bundler-0.9.25/lib/bundler/environment.rb:55:in resolve' from /Users/jenya/r3/gems/bundler-0.9.25/lib/bundler/environment.rb:59:inresolve_locally'
from /Users/jenya/r3/gems/bundler-0.9.25/lib/bundler/environment.rb:28:in specs' from /Users/jenya/r3/gems/bundler-0.9.25/lib/bundler/runtime.rb:17:insetup'
from /Users/jenya/r3/gems/bundler-0.9.25/lib/bundler.rb:76:in gem_setup' from /Users/jenya/projects/finance/config/boot.rb:4:in

'

The main issue IMHO is runtime.rb:14. It just removes all the load path's including ruby libraries itself. Code shared_helpers.rb:69 proves it. All the load path's are just removed since I have everything in ${HOME}/r3

@indirect
Copy link
Member

Can you reproduce this bug on ruby 1.8.7 or ruby 1.9.2?

@dtsadok
Copy link

dtsadok commented Oct 24, 2010

I can reproduce this bug. Ruby 1.9.2 on Red Hat. I have RUBYLIB and GEM_PATH set to the non-standard /local. I get a LoadError for "set" as well.

irb(main):001:0> require 'bundler'
=> true
irb(main):002:0> require 'set'
=> true
irb(main):003:0> Bundler.setup
LoadError: no such file to load -- set

Unsetting RUBYLIB doesn't help, and unsetting GEM_PATH prevents me from even being able to load Bundler. I also have RUBYOPT="-rubygems", but unsetting that also has no effect.

@dtsadok
Copy link

dtsadok commented Oct 24, 2010

In one line:
$ ruby -rbundler -e "Bundler.setup"

@indirect
Copy link
Member

dtsadok, I'm having trouble reproducing this on my local machine. What do you get if you run ruby -rbundler -e "puts $LOAD_PATH"? What is the backtrace on your error? Do you have any other environment variables set? Thanks.

@dtsadok
Copy link

dtsadok commented Oct 25, 2010

Before I get into the code you asked for, I just wanted to mention that I'm not using rvm. I can repro on several different machines with exactly the same setup.

RUBYLIB is /local/lib/ruby/site_ruby/1.9.1/x86_64-linux/

I have pretty much all my gems in /local, but ruby itself, as well as most built-in libraries, like "set", are in /usr/local (which is nfs-mounted read-only on my machine, and I can't access).

Also, if I print $LOAD_PATH right before the "require 'set'" line in lib/bundler/resolver.rb, I get this:
$ ruby -rbundler -e "Bundler.setup"
/local/gems/bundler-1.0.3/lib
internal:lib/rubygems/custom_require:29:in `require': no such file to load -- set (LoadError)
<snip - stacktrace is further down>

What other environment variables might be relevant? I listed all the Ruby ones (GEM_HOME doesn't seem to change anything). I can dump my whole env if you think that will help...

Anyway, as you asked:
$ ruby -e "puts $LOAD_PATH"
(nothing)

$ ruby -rbundler -e "puts $LOAD_PATH"
(nothing)

$ ruby -e "puts $:"
/local/lib/ruby/site_ruby/1.9.1/x86_64-linux/
/usr/local/lib/ruby/site_ruby/1.9.1
/usr/local/lib/ruby/site_ruby/1.9.1/x86_64-linux
/usr/local/lib/ruby/site_ruby
/usr/local/lib/ruby/vendor_ruby/1.9.1
/usr/local/lib/ruby/vendor_ruby/1.9.1/x86_64-linux
/usr/local/lib/ruby/vendor_ruby
/usr/local/lib/ruby/1.9.1
/usr/local/lib/ruby/1.9.1/x86_64-linux

$ ruby -rbundler -e "puts $:"
/local/lib/ruby/site_ruby/1.9.1/x86_64-linux/
/local/gems/bundler-1.0.3/bin
/local/gems/bundler-1.0.3/lib
/usr/local/lib/ruby/site_ruby/1.9.1
/usr/local/lib/ruby/site_ruby/1.9.1/x86_64-linux
/usr/local/lib/ruby/site_ruby
/usr/local/lib/ruby/vendor_ruby/1.9.1
/usr/local/lib/ruby/vendor_ruby/1.9.1/x86_64-linux
/usr/local/lib/ruby/vendor_ruby
/usr/local/lib/ruby/1.9.1
/usr/local/lib/ruby/1.9.1/x86_64-linux

$ irb
irb(main):001:0> puts $LOAD_PATH
/local/lib/ruby/site_ruby/1.9.1/x86_64-linux/
/usr/local/lib/ruby/site_ruby/1.9.1
/usr/local/lib/ruby/site_ruby/1.9.1/x86_64-linux
/usr/local/lib/ruby/site_ruby
/usr/local/lib/ruby/vendor_ruby/1.9.1
/usr/local/lib/ruby/vendor_ruby/1.9.1/x86_64-linux
/usr/local/lib/ruby/vendor_ruby
/usr/local/lib/ruby/1.9.1
/usr/local/lib/ruby/1.9.1/x86_64-linux
=> nil
irb(main):002:0> require 'bundler'
=> true
irb(main):003:0> puts $LOAD_PATH
/local/lib/ruby/site_ruby/1.9.1/x86_64-linux/
/local/gems/bundler-1.0.3/bin
/local/gems/bundler-1.0.3/lib
/usr/local/lib/ruby/site_ruby/1.9.1
/usr/local/lib/ruby/site_ruby/1.9.1/x86_64-linux
/usr/local/lib/ruby/site_ruby
/usr/local/lib/ruby/vendor_ruby/1.9.1
/usr/local/lib/ruby/vendor_ruby/1.9.1/x86_64-linux
/usr/local/lib/ruby/vendor_ruby
/usr/local/lib/ruby/1.9.1
/usr/local/lib/ruby/1.9.1/x86_64-linux
=> nil

Last but not least:
$ ruby -rbundler -e "Bundler.setup"
internal:lib/rubygems/custom_require:29:in require': no such file to load -- set (LoadError) from <internal:lib/rubygems/custom_require>:29:inrequire'
from /local/gems/bundler-1.0.3/lib/bundler/resolver.rb:1:in <top (required)>' from /local/gems/bundler-1.0.3/lib/bundler/definition.rb:153:inresolve'
from /local/gems/bundler-1.0.3/lib/bundler/definition.rb:93:in specs' from /local/gems/bundler-1.0.3/lib/bundler/definition.rb:137:inspecs_for'
from /local/gems/bundler-1.0.3/lib/bundler/definition.rb:126:in requested_specs' from /local/gems/bundler-1.0.3/lib/bundler/environment.rb:23:inrequested_specs'
from /local/gems/bundler-1.0.3/lib/bundler/runtime.rb:11:in setup' from /local/gems/bundler-1.0.3/lib/bundler.rb:100:insetup'
from -e:1:in `

'

Looks to me that Bundler.setup is blowing away $: and/or $LOAD_PATH on my machine, at least.

Hope this helps repro :-P

Thanks for taking a look!
--Daniel

@indirect
Copy link
Member

Thanks, hopefully I can repro it now. One last question -- are you using Ruby 1.9.1 deliberately? It has so many bugs (many of which have affected Bundler users) that I am sorry to say we are unable to support it, and strongly suggest using 1.9.2 instead.

@dtsadok
Copy link

dtsadok commented Oct 26, 2010

I'm using Ruby 1.9.2. But the libraries as installed are 1.9.1 (I was confused too).
See FAQ on this page: http://www.ruby-lang.org/en/news/2010/08/18/ruby-1-9-2-is-released/

@dtsadok
Copy link

dtsadok commented Nov 4, 2010

I think I narrowed down the issue. It's in clean_load_path, with the following condition:
Gem.path.any? { |gp| p.include?(gp) }

which is inside a $LOAD_PATH.reject! block (sorry I don't know how to do inline code :-P)

My Gem.path is ["/local"], and p is each of the $LOAD_PATH entries as above. So the result is:
#gp is "/local"
#p is "/usr/local/lib/ruby/site_ruby"
p.include?(gp) #evaluates to true

So the path is rejected. Maybe the reject condition can be a regex instead of simply include?().

I don't know enough about how Bundler works and what clean_load_path is for to fix it, but it's clearly over-zealous with its cleaning in my setup. I'll try monkey-patching it, I guess.

Best,
--Daniel

@indirect
Copy link
Member

indirect commented Nov 4, 2010

Thanks for tracking this down! It sounds like a regex is the way to go.

@indirect
Copy link
Member

indirect commented Nov 4, 2010

p.include? is not a legitimate path comparison

Closed by 7d0ec38

joevandyk pushed a commit to joevandyk/bundler that referenced this issue May 16, 2011
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants