summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Arko <mail@arko.net>2015-07-20 14:04:55 -0700
committerAndré Arko <mail@arko.net>2015-07-20 14:04:55 -0700
commit0854c6e83785a097aaf59e7398d52f2b924ed94f (patch)
tree5f3352a0cec2802a7f8461c906c6d1a1bc568c8d
parent9ba2334dd2995c5909c8b751ac0dbe672a301e3e (diff)
parent684be9b7bcd3c35b4d71ad752e775d217d13c120 (diff)
downloadbundler-0854c6e83785a097aaf59e7398d52f2b924ed94f.tar.gz
Merge pull request #3837 from smlance/sml-fix-default-install-path-2-0-dev
Ensure configured relative paths are expanded from the Gemfile directory
-rw-r--r--lib/bundler/settings.rb28
-rw-r--r--lib/bundler/source/rubygems.rb4
-rw-r--r--spec/install/path_spec.rb1
3 files changed, 28 insertions, 5 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 8be66976f4..0745709782 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -12,6 +12,10 @@ module Bundler
@global_config = load_config(global_config_file)
end
+ def root
+ @root
+ end
+
def [](name)
key = key_for(name)
value = (@local_config[key] || ENV[key] || @global_config[key] || DEFAULT_CONFIG[name])
@@ -130,20 +134,38 @@ module Bundler
end
# @local_config["BUNDLE_PATH"] should be prioritized over ENV["BUNDLE_PATH"]
+ # Always returns an absolute path to the bundle directory
+ # TODO: Document and refactor this method
def path
key = key_for(:path)
path = ENV[key] || @global_config[key]
+ set_path = ""
+ install_path = ""
if path && !@local_config.key?(key)
path = "#{path}/#{Bundler.ruby_scope}" if path != Bundler.rubygems.gem_dir
- return path
+ set_path = path
end
if path = self[:path]
path = "#{path}/#{Bundler.ruby_scope}" if path != Bundler.rubygems.gem_dir
- File.expand_path(path)
+ set_path = path
+ else
+ set_path = File.join(@root, Bundler.ruby_scope)
+ end
+
+ if set_path == File.join(Bundler.settings.root, Bundler.ruby_scope)
+ # ?
+ install_path = set_path
+ elsif set_path == Bundler.rubygems.gem_dir
+ # system gems path
+ install_path = set_path
+ elsif Pathname.new(set_path).absolute?
+ # all other absolute paths
+ install_path = set_path
else
- File.join(@root, Bundler.ruby_scope)
+ # all relative paths (configured by the user)
+ install_path = File.join(Bundler::root, set_path)
end
end
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index d95f9181b5..5a8525ef0c 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -126,8 +126,8 @@ module Bundler
install_path = Bundler.tmp(spec.full_name)
bin_path = install_path.join("bin")
else
- install_path = File.expand_path(Bundler.settings.path)
- bin_path = Bundler.system_bindir
+ install_path = Bundler.settings.path
+ bin_path = Bundler.system_bindir
end
installed_spec = nil
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index 420e8b162e..8ec8f2c50b 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -92,6 +92,7 @@ describe "bundle install" do
# FIXME: If the bundle_path is `"vendor"` instead of
# `bundled_app("vendor").to_s`, this spec fails. As is, this spec
# may not test what happens when `path` is relative.
+
bundle "config path vendor"
#set_bundle_path(type, bundled_app("vendor").to_s)