Skip to content
Browse files

Fix a bug with multiruby and bundle_path

  • Loading branch information...
1 parent c3c08e3 commit 0021df9cb1beae0f61f0f9e9a1a1375a17734d30 Carlhuda committed Jan 4, 2010
Showing with 22 additions and 15 deletions.
  1. +9 −9 lib/bundler/bundle.rb
  2. +1 −1 lib/bundler/dsl.rb
  3. +4 −4 spec/bundler/cli_spec.rb
  4. +7 −0 spec/bundler/manifest_file_spec.rb
  5. +1 −1 spec/support/path_utils.rb
View
18 lib/bundler/bundle.rb
@@ -26,10 +26,6 @@ def self.default_gemfile
raise DefaultManifestNotFound
end
- def self.default_gem_path(root)
- root.join("vendor/gems/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}")
- end
-
# TODO: passing in the filename is not good
def initialize(gemfile)
@gemfile = gemfile
@@ -51,12 +47,16 @@ def root
gemfile.parent
end
- def gem_path
- @gem_path ||= self.class.default_gem_path(root)
+ def path
+ @path ||= root.join("vendor/gems")
end
- def gem_path=(path)
- @gem_path = (path.relative? ? root.join(path) : path).expand_path
+ def path=(path)
+ @path = (path.relative? ? root.join(path) : path).expand_path
+ end
+
+ def gem_path
+ path.join("#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}")
end
def bindir
@@ -309,7 +309,7 @@ def configure(specs, options)
end
def generate_environment_picker
- FileUtils.cp("#{File.dirname(__FILE__)}/templates/environment_picker.erb", gem_path.join("../../environment.rb"))
+ FileUtils.cp("#{File.dirname(__FILE__)}/templates/environment_picker.erb", path.join("environment.rb"))
end
def require_code(file, dep)
View
2 lib/bundler/dsl.rb
@@ -19,7 +19,7 @@ def initialize(bundle, environment)
end
def bundle_path(path)
- @bundle.gem_path = Pathname.new(path)
+ @bundle.path = Pathname.new(path)
end
def bin_path(path)
View
8 spec/bundler/cli_spec.rb
@@ -188,7 +188,7 @@
describe "it working while specifying the manifest file name" do
it "works when the manifest is in the root directory" do
- build_manifest_file bundled_app('manifest.rb'), <<-Gemfile
+ manifest = build_manifest bundled_app('manifest.rb'), <<-Gemfile
bundle_path "gems"
clear_sources
source "file://#{gem_repo1}"
@@ -198,13 +198,13 @@
Dir.chdir(bundled_app) do
out = gem_command :bundle, "-m #{bundled_app('manifest.rb')}"
out.should include('Done.')
- bundled_app("gems").should have_cached_gems("rake-0.8.7")
+ manifest.gem_path.should have_cached_gems("rake-0.8.7")
tmp_bindir('rake').should exist
end
end
it "works when the manifest is in a different directory" do
- build_manifest_file bundled_app('config', 'manifest.rb'), <<-Gemfile
+ manifest = build_manifest bundled_app('config', 'manifest.rb'), <<-Gemfile
bundle_path "../gems"
clear_sources
source "file://#{gem_repo1}"
@@ -214,7 +214,7 @@
Dir.chdir(bundled_app)
out = gem_command :bundle, "-m #{bundled_app('config', 'manifest.rb')}"
out.should include('Done.')
- bundled_app("gems").should have_cached_gems("rake-0.8.7")
+ manifest.gem_path.should have_cached_gems("rake-0.8.7")
end
it "works when using a relative path to the manifest file" do
View
7 spec/bundler/manifest_file_spec.rb
@@ -54,6 +54,13 @@ def works
bundled_app('gems').should exist
end
+ it "sets the ruby-specific path relative to the bundle_path" do
+ simple_manifest %[bundle_path File.join('..', 'cheezeburgerz')]
+ goto 'w0t'
+ bundle
+ tmp_path("cheezeburgerz", Gem.ruby_engine, Gem::ConfigMap[:ruby_version], "environment.rb").should exist
+ end
+
it "assumes the bundle_path is relative to the manifest file no matter what the current working dir is" do
simple_manifest %[bundle_path File.join('..', 'cheezeburgerz')]
goto 'w0t'
View
2 spec/support/path_utils.rb
@@ -15,7 +15,7 @@ def bundled_app(*path)
end
def bundled_path
- @bundled_path ||= Bundler::Bundle.default_gem_path(tmp_path.join('bundled_app'))
+ @bundled_path ||= bundled_app("vendor/gems/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}")
end
def tmp_gem_path(*path)

0 comments on commit 0021df9

Please sign in to comment.
Something went wrong with that request. Please try again.