Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Make install --path relative to the cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbozato authored and segiddins committed Sep 8, 2017
1 parent 52bdb41 commit c69452e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bundler/cli/install.rb
Expand Up @@ -170,7 +170,7 @@ def normalize_groups
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"]
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/feature_flag.rb
Expand Up @@ -44,6 +44,7 @@ def self.settings_method(name, key, &default)
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? }
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/settings.rb
Expand Up @@ -43,6 +43,7 @@ class Settings
no_install
no_prune
only_update_to_newer_versions
path_relative_to_cwd
path.system
plugins
prefer_gems_rb
Expand Down
2 changes: 2 additions & 0 deletions man/bundle-config.ronn
Expand Up @@ -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`)
Expand Down
12 changes: 12 additions & 0 deletions spec/install/path_spec.rb
Expand Up @@ -49,6 +49,18 @@
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
Expand Down

0 comments on commit c69452e

Please sign in to comment.