-
-
Save indirect/b8d47d4ca590e7b00539 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[andre ~/sw/gems/bundler-testcases/i850]$ cat Gemfile | |
gem "rack" | |
[andre ~/sw/gems/bundler-testcases/i850]$ dbundle install | |
Using rack (1.2.1) | |
Using bundler (1.0.5) | |
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. | |
[andre ~/sw/gems/bundler-testcases/i850]$ cat test.rb | |
require 'rubygems' | |
require 'bundler/setup' | |
puts "With env: #{ENV['BUNDLE_GEMFILE']}" | |
Bundler.with_clean_env do | |
puts "With clean: #{ENV['BUNDLE_GEMFILE']}" | |
end | |
[andre ~/sw/gems/bundler-testcases/i850]$ echo $BUNDLE_GEMFILE | |
[andre ~/sw/gems/bundler-testcases/i850]$ ruby test.rb | |
With env: /Users/andre/sw/gems/bundler-testcases/i850/Gemfile | |
With clean: |
Sorry, I don't understand your question. What do you want to be able to do?
From an application, load code which may itself have distinct dependencies described in separate Gemfiles. Plugins are a canonical example - it would be nice to be able to distribute plugins with 'bundle install --deployment' dependencies which can be loaded from the parent application without requiring all possible plugin dependencies to be added to the app Gemfile a priori.
No, unfortunately that's not possible. The ruby interpreter is only able to load a single set of libraries, which is why Bundler has to resolve the entire dependency graph before the interpreter even starts.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way to make nested loading of code with bundle-configured dependencies work?
[aaron@msi-cr620 bundle-plugins]$ cat Gemfile
source "http://rubygems.org"
[aaron@msi-cr620 bundle-plugins]$ cat app.rb
require "rubygems"
require "bundler"
Bundler.setup(:default)
require 'veritas'
[aaron@msi-cr620 bundle-plugins]$ cat plugins/Gemfile
source "http://rubygems.org"
[aaron@msi-cr620 bundle-plugins]$ cat plugins/sample.rb
require "rubygems"
require "bundler"
[aaron@msi-cr620 bundle-plugins]$ ls plugins/vendor/bundle/ruby/1.8/gems/
json_pure-1.5.1
[aaron@msi-cr620 bundle-plugins]$ ruby app.rb
With env: /home/aaron/workspace/bundle-plugins/Gemfile
Changing to dir: /home/aaron/workspace/bundle-plugins/plugins
With clean:
Requiring /home/aaron/workspace/bundle-plugin/plugins/sample.rb
In plugin env: /home/aaron/workspace/bundle-plugins/plugins/Gemfile
/home/aaron/workspace/bundle-plugins/plugins/sample.rb:6:in `require': no such file to load -- json/pure (LoadError)
[aaron@msi-cr620 bundle-plugins]$ cd plugins/; ruby ../app.rb
../app.rb:4:in `require': no such file to load -- veritas (LoadError)