summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Bozato <igor.hrk@gmail.com>2017-06-21 15:36:59 -0300
committerSamuel Giddins <segiddins@segiddins.me>2017-09-08 10:46:55 -0700
commitc69452ecc970818cdabf045ce3c06ed8907aa559 (patch)
treeca79e16228588aa493ad16cbb33e1962b9874236
parent52bdb41ef5ae81f9faa659a6770706f6a20d555a (diff)
downloadbundler-c69452ecc970818cdabf045ce3c06ed8907aa559.tar.gz
Make `install --path` relative to the cwd
-rw-r--r--lib/bundler/cli/install.rb2
-rw-r--r--lib/bundler/feature_flag.rb1
-rw-r--r--lib/bundler/settings.rb1
-rw-r--r--man/bundle-config.ronn2
-rw-r--r--spec/install/path_spec.rb12
5 files changed, 17 insertions, 1 deletions
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index f0b821ed84..3f4b4f7239 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -170,7 +170,7 @@ module Bundler
def normalize_settings
Bundler.settings.set_command_option :path, nil if options[:system]
Bundler.settings.set_command_option :path, "vendor/bundle" if options[:deployment]
- Bundler.settings.set_command_option_if_given :path, options["path"]
+ Bundler.settings.set_command_option :path, Bundler.feature_flag.path_relative_to_cwd? ? File.expand_path(options["path"]) : options["path"] if options["path"]
Bundler.settings.set_command_option :path, "bundle" if options["standalone"] && Bundler.settings[:path].nil?
bin_option = options["binstubs"]
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index d6618379da..f7bb5d1cf8 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -44,6 +44,7 @@ module Bundler
settings_flag(:list_command) { bundler_2_mode? }
settings_flag(:lockfile_uses_separate_rubygems_sources) { bundler_2_mode? }
settings_flag(:only_update_to_newer_versions) { bundler_2_mode? }
+ settings_flag(:path_relative_to_cwd) { bundler_2_mode? }
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
settings_flag(:prefer_gems_rb) { bundler_2_mode? }
settings_flag(:print_only_version_number) { bundler_2_mode? }
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 5f01e7a376..6e4f04f3ef 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -43,6 +43,7 @@ module Bundler
no_install
no_prune
only_update_to_newer_versions
+ path_relative_to_cwd
path.system
plugins
prefer_gems_rb
diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn
index f1f3062aea..3d3063dfb3 100644
--- a/man/bundle-config.ronn
+++ b/man/bundle-config.ronn
@@ -218,6 +218,8 @@ learn more about their operation in [bundle install(1)][bundle-install].
is used, defaults to vendor/bundle.
* `path.system` (`BUNDLE_PATH__SYSTEM`):
Whether Bundler will install gems into the default system path (`Gem.dir`).
+* `path_relative_to_cwd` (`PATH_RELATIVE_TO_CWD`)
+ Makes `--path` relative to the CWD instead of the `Gemfile`.
* `plugins` (`BUNDLE_PLUGINS`):
Enable Bundler's experimental plugin system.
* `prefer_gems_rb` (`BUNDLE_PREFER_GEMS_RB`)
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index fb356899a6..2de2f5983d 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -49,6 +49,18 @@ RSpec.describe "bundle install" do
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
expect(the_bundle).to include_gems "rack 1.0.0"
end
+
+ context "with path_relative_to_cwd set to true" do
+ before { bundle! "config path_relative_to_cwd true" }
+
+ it "installs the bundle relatively to current working directory" do
+ Dir.chdir(bundled_app.parent) do
+ bundle "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle"
+ expect(out).to include("installed into ./vendor/bundle")
+ expect(Dir.exist?("vendor/bundle")).to be true
+ end
+ end
+ end
end
describe "when BUNDLE_PATH or the global path config is set" do