Skip to content

Instantly share code, notes, and snippets.

@abargnesi
Created July 18, 2014 03:08
Show Gist options
  • Save abargnesi/1ac06c31e76296f0df40 to your computer and use it in GitHub Desktop.
Save abargnesi/1ac06c31e76296f0df40 to your computer and use it in GitHub Desktop.
'bundler package --all' fails to find git-sourced gem if Bundler.setup is called twice. Fails in '3_terminal_multiple.md' as well as with the '4_example.rb'.
source 'https://rubygems.org'
gem 'bel', :git => 'https://github.com/OpenBEL/bel.rb.git'
$ BUNDLE_GEMFILE=Gemfile_only_git bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Using bel 0.3.0 from https://github.com/OpenBEL/bel.rb.git (at master)
Using bundler 1.6.3
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

$ BUNDLE_GEMFILE=Gemfile_only_git RUBYOPT="-rbundler/setup.rb" bundle package --all
Using bel 0.3.0 from https://github.com/OpenBEL/bel.rb.git (at master)
Using bundler 1.6.3
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
Updating files in vendor/cache

$ ls vendor/cache/
total 4
drwxrwxr-x 6 tony tony 4096 Jul 17 22:38 bel.rb-fb260bb2a861

$ rm -fr $HOME/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/bel.rb-fb260bb2a861/
$ rm -fr .bundle/ vendor/
source 'https://rubygems.org'
gem 'bel', :git => 'https://github.com/OpenBEL/bel.rb.git'
gem 'sinatra'
$ BUNDLE_GEMFILE=Gemfile_multiple bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Using bel 0.3.0 from https://github.com/OpenBEL/bel.rb.git (at master)
Using rack 1.5.2
Using rack-protection 1.5.3
Using tilt 1.4.1
Using sinatra 1.4.5
Using bundler 1.6.3
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

$ BUNDLE_GEMFILE=Gemfile_multiple RUBYOPT="-rbundler/setup.rb" bundle package --all
Using bel 0.3.0
Using rack 1.5.2
Using rack-protection 1.5.3
Using tilt 1.4.1
Using sinatra 1.4.5
Using bundler 1.6.3
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
Updating files in vendor/cache
Could not find bel-0.3.0.gem for installation

$ echo $?
7
#!/usr/bin/env ruby
# Using the following set RUBYOPT to "-rbundler/setup.rb" which
# causes a 'bundle' subprocess to invoke bundler again...the effect
# is that git gems can no longer be found when packaging to vendor/cache.
#
require 'rubygems'
require 'bundler'
Bundler.setup(:development)
# require a development gem dependencies
require 'term/ansicolor'
# This call exits with status 7.
# Message: Could not find bel-0.3.0.gem for installation
system('bundle package --all')
# ...
# ...
@abargnesi
Copy link
Author

It seems the RUBYOPT environment variable is set to "-rbundler/setup.rb" once Bundler.setup is called (lib/bundler/runtime.rb:233). That env var then propagates to the subshell command "bundle package --all".

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