From a3fa32a57817074a1b2056c587aa5114371ea01d Mon Sep 17 00:00:00 2001 From: Stefan Lance Date: Thu, 16 Jul 2015 14:40:51 -0500 Subject: [PATCH] Modify installation path Conflicts: lib/bundler/source_list.rb --- lib/bundler/settings.rb | 6 +++++- lib/bundler/source/rubygems.rb | 17 +++++++++++++++-- spec/install/path_spec.rb | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 8be66976f4e..f5eede64804 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -12,6 +12,10 @@ def initialize(root = nil) @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]) @@ -141,7 +145,7 @@ def path if path = self[:path] path = "#{path}/#{Bundler.ruby_scope}" if path != Bundler.rubygems.gem_dir - File.expand_path(path) + path else File.join(@root, Bundler.ruby_scope) end diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index d95f9181b56..1da1aaf2476 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -126,8 +126,21 @@ def install(spec, opts = {}) 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 + + set_path = Bundler.settings.path + + # TODO: document exactly what's going on here and in Bundler.settings.path + if set_path == File.join(Bundler.settings.root, Bundler.ruby_scope) # ? + install_path = Bundler.settings.path + elsif set_path == Bundler.rubygems.gem_dir # system gems path + install_path = Bundler.settings.path + elsif Pathname.new(set_path).absolute? # all other absolute paths + install_path = Bundler.settings.path + else # all relative paths + install_path = File.join(Bundler::root, Bundler.settings.path) + end + + bin_path = Bundler.system_bindir end installed_spec = nil diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb index 420e8b162e0..8ec8f2c50b7 100644 --- a/spec/install/path_spec.rb +++ b/spec/install/path_spec.rb @@ -92,6 +92,7 @@ def set_bundle_path(type, location) # 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)