rvm/rubygems-bundler

Breaking the spring gem

diabolo opened this issue · 6 comments

I'm debugging an issue with the spring gem failing to load. This has lead me (down a long long trail) to rubygems-bundler. Hopefully the following trace will show the issue

[81, 90] in /Users/andy/.rvm/gems/ruby-1.9.3-p448@global/gems/rubygems-bundler-1.4.1/lib/rubygems-bundler/noexec.rb
   81        if File.file?(gemfile) && candidate?
   82          log "Keeping #{gemfile} loaded"
   83          Bundler.setup
   84          return
   85        end
=> 86        new_gemfile = File.expand_path("../../Gemfile", gemfile)
   87        break if new_gemfile == gemfile
   88        @gemfile = new_gemfile
   89      end
   90      log "No valid Gemfile found, moving on"
(rdb:1) gemfile
"/Users/andy/Sites/futuregov/patchwork/Gemfile"    # <- actual location of Gemfile
(rdb:1) n
/Users/andy/.rvm/gems/ruby-1.9.3-p448@global/gems/rubygems-bundler-1.4.1/lib/rubygems-bundler/noexec.rb:87
break if new_gemfile == gemfile

[82, 91] in /Users/andy/.rvm/gems/ruby-1.9.3-p448@global/gems/rubygems-bundler-1.4.1/lib/rubygems-bundler/noexec.rb
   82          log "Keeping #{gemfile} loaded"
   83          Bundler.setup
   84          return
   85        end
   86        new_gemfile = File.expand_path("../../Gemfile", gemfile)
=> 87        break if new_gemfile == gemfile
   88        @gemfile = new_gemfile                   
   89      end
   90      log "No valid Gemfile found, moving on"
   91    rescue LoadError
(rdb:1) new_gemfile
"/Users/andy/Sites/futuregov/Gemfile"         # <- NO GEMFILE HERE

Now I have no idea why this code is doing what its doing, or even if its wrong (it doesn't look correct), but the fact that Spring is failing with /Gemfile not found, and that somehow this code is executing when Spring runs (it loads bundler) makes me very suspicious.

Perhaps the code should check if the existing gemfile is actually a file before changing its path. Doing this after changing its path might also be an idea.

TIA

Andrew

oh interesting, please check this setup function:

  def setup
    puts "Noexec - starting check" if Noexec::DEBUG
    require "bundler-unload"

    @rubygems_specs = Bundler.rubygems.plain_specs # save it for unloading and checking binary
    log2 "rubygems_specs: #{rubygems_specs.map{|g| "#{g.name}-#{g.version}"}*" "}"

    @gemfile = ENV['BUNDLE_GEMFILE'] || File.join(Noexec::CURRENT, "Gemfile")
    initial_env_gemfile = ENV['BUNDLE_GEMFILE']

    while true
      ENV['BUNDLE_GEMFILE'] = gemfile
      if File.file?(gemfile) && candidate?
        log "Keeping #{gemfile} loaded"
        Bundler.setup
        return
      end
      new_gemfile = File.expand_path("../../Gemfile", gemfile)
      break if new_gemfile == gemfile
      @gemfile = new_gemfile
    end
    log "No valid Gemfile found, moving on"
    ENV['BUNDLE_GEMFILE'] = initial_env_gemfile
  rescue LoadError
    warn "bundler not being used, unable to load" if Noexec::DEBUG
    ENV['BUNDLE_GEMFILE'] = initial_env_gemfile
  end

Hey, that seems to work just fine, tx

released 1.4.2

Hey, how do we get this into our rvm installations

Cheers

Andrew

this should be enough:

rvm @global do gem update rubygems-bundler

This took me a while to find. I started having this problem when I reformatted my MBA for Mavericks. I obviously just caught the tail end of the previous version. A horrible bug to find.

For anyone Googling a similar problem. I couldn't use Foreman to start anything in my Rails app, because Foreman wasn't in my Gemfile, so rubygems-bundler was setting my BUNDLE_GEMFILE environment variable to '/Gemfile' (because it considered the Gemfile to be invalid) which would cause everything Foreman tried to start to fail.

Updating the gem fixes the issue. Thanks! 👍