Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Bundler prevents Gem methods from seeing multiple gem paths #862

Closed
elskwid opened this Issue Nov 19, 2010 · 1 comment

Comments

Projects
None yet
2 participants

elskwid commented Nov 19, 2010

Overview

When using Bundler in combination with rvm and Warbler, the calls to Gem.source_index.search() in Warbler aren't able to see gems installed in the global gemset.

Details

Bundler v 1.0.7
rvm v 1.1.0 (head branch at the time of this ticket)
Warbler 1.3.0.beta1

  • Bundler gem is installed under global gemset in rvm, along with a few other gems
  • All other application (rails 2.3.5) gems are installed under a project gemset
  • Warbler uses Gemfile and Gemfile.lock to create a list of gems that get copied into the war file

The result in this case is the generated war file contains all the gems except bundler. When the rails application spins up and the call to Bundler.require is made in boot.rb, it fails as there is no bundler to be found.

Investigation

I've been looking at this for two days now and have found a little that may help with a solution.

First

RVM sets the following pertinent environment variables:

GEM_HOME=/Users/donm/.rvm/gems/jruby-1.5.5@console
GEM_PATH=/Users/donm/.rvm/gems/jruby-1.5.5@console:/Users/donm/.rvm/gems/jruby-1.5.5@global

(Bundler is installed under @global)

Then

Bundler resets gem paths in at least two places:

Bundler::SharedHelpers#cripple_rubygems

Gem.clear_paths

Bundler#configure_gem_home_and_path

ENV['GEM_PATH'] = ''
ENV['GEM_HOME'] = File.expand_path(bundle_path, root)

The latter looks like the situation in my case.

Finally

Warbler uses Gem to gather up the gems for the .war file:

Warbler::War#find_single_gem_files

matched = Gem.source_index.search(gem)

The search on Gem doesn't have any knowledge of the GEM_PATH from above as it is cleared by Bundler. Gem then can only use GEM_HOME, which doesn't have the needed gem.

I tried to force bundler into the gem list that Warbler uses and at that point an error is thrown that the gem is not installed.

Steps to reproduce

_ You should have a Rails project to try out _

  • install rvm

    bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

  • install JRuby 1.5.5

    rvm install jruby-1.5.5

  • switch to jruby

    rvm use jruby-1.5.5

  • switch to global gemset

    rvm gemset use global

  • install bundler gem

    gem install bundler

  • create local gemset

    rvm gemset create local

  • switch to local gemset

    rvm gemset use local

  • install warbler

    gem install warbler -v 1.3.0.beta1

  • switch to rails application directory

    cd PATH/TO/APP

  • install rails application gems

    bundle install

  • create war file

    warble war

  • unpack war file

    unzip (or watever) PATH/TO/.war

  • gems should be in warname/WEB-INF/gems/gem/...

In my case, bundler is not here.

Contributor

xaviershay commented Aug 10, 2013

This is a fantastic report but it is three years old so I'm closing it. Please feel free to re-open with a repro on latest bundler.

@xaviershay xaviershay closed this Aug 10, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment