mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[rubygems/rubygems] Cancel path_relative_to_cwd
change
It only affected the `--path` flag which is actually getting removed, so
I don't think it makes sense to make such change. The current behavior
is reasonable and I tried to codify it with a few more specs.
6f520eb146
This commit is contained in:
parent
5fa484a441
commit
cd3389e5c2
7 changed files with 32 additions and 52 deletions
|
@ -160,9 +160,7 @@ module Bundler
|
|||
Bundler.settings.set_command_option_if_given :path, options[:path]
|
||||
|
||||
if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
|
||||
Bundler.settings.temporary(path_relative_to_cwd: false) do
|
||||
Bundler.settings.set_command_option :path, "bundle"
|
||||
end
|
||||
Bundler.settings.set_command_option :path, "bundle"
|
||||
end
|
||||
|
||||
bin_option = options["binstubs"]
|
||||
|
|
|
@ -32,7 +32,6 @@ module Bundler
|
|||
settings_flag(:forget_cli_options) { bundler_4_mode? }
|
||||
settings_flag(:global_gem_cache) { bundler_4_mode? }
|
||||
settings_flag(:lockfile_checksums) { bundler_4_mode? }
|
||||
settings_flag(:path_relative_to_cwd) { bundler_4_mode? }
|
||||
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
|
||||
settings_flag(:setup_makes_kernel_gem_public) { !bundler_4_mode? }
|
||||
settings_flag(:update_requires_all_flag) { bundler_5_mode? }
|
||||
|
|
|
@ -146,9 +146,6 @@ The location on disk where all gems in your bundle will be located regardless of
|
|||
\fBpath\.system\fR (\fBBUNDLE_PATH__SYSTEM\fR)
|
||||
Whether Bundler will install gems into the default system path (\fBGem\.dir\fR)\.
|
||||
.TP
|
||||
\fBpath_relative_to_cwd\fR (\fBBUNDLE_PATH_RELATIVE_TO_CWD\fR)
|
||||
Makes \fB\-\-path\fR relative to the CWD instead of the \fBGemfile\fR\.
|
||||
.TP
|
||||
\fBplugins\fR (\fBBUNDLE_PLUGINS\fR)
|
||||
Enable Bundler's experimental plugin system\.
|
||||
.TP
|
||||
|
|
|
@ -168,8 +168,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
|
|||
before Bundler 4.
|
||||
* `path.system` (`BUNDLE_PATH__SYSTEM`):
|
||||
Whether Bundler will install gems into the default system path (`Gem.dir`).
|
||||
* `path_relative_to_cwd` (`BUNDLE_PATH_RELATIVE_TO_CWD`):
|
||||
Makes `--path` relative to the CWD instead of the `Gemfile`.
|
||||
* `plugins` (`BUNDLE_PLUGINS`):
|
||||
Enable Bundler's experimental plugin system.
|
||||
* `prefer_patch` (BUNDLE_PREFER_PATCH):
|
||||
|
|
|
@ -34,7 +34,6 @@ module Bundler
|
|||
lockfile_checksums
|
||||
no_install
|
||||
no_prune
|
||||
path_relative_to_cwd
|
||||
path.system
|
||||
plugins
|
||||
prefer_patch
|
||||
|
|
|
@ -74,29 +74,6 @@ module Bundler
|
|||
fail!(key, value, "`#{other_key}` is current set to #{other_setting.inspect}", "the `#{conflicting.join("`, `")}` groups conflict")
|
||||
end
|
||||
end
|
||||
|
||||
rule %w[path], "relative paths are expanded relative to the current working directory" do |key, value, settings|
|
||||
next if value.nil?
|
||||
|
||||
path = Pathname.new(value)
|
||||
next if !path.relative? || !Bundler.feature_flag.path_relative_to_cwd?
|
||||
|
||||
path = path.expand_path
|
||||
|
||||
root = begin
|
||||
Bundler.root
|
||||
rescue GemfileNotFound
|
||||
Pathname.pwd.expand_path
|
||||
end
|
||||
|
||||
path = begin
|
||||
path.relative_path_from(root)
|
||||
rescue ArgumentError
|
||||
path
|
||||
end
|
||||
|
||||
set(settings, key, path.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -59,29 +59,41 @@ RSpec.describe "bundle install" do
|
|||
expect(the_bundle).to include_gems "myrack 1.0.0"
|
||||
end
|
||||
|
||||
context "with path_relative_to_cwd set to true" do
|
||||
before { bundle "config set path_relative_to_cwd true" }
|
||||
it "installs the bundle relatively to repository root, when Bundler run from the same directory" do
|
||||
bundle "config path vendor/bundle", dir: bundled_app.parent
|
||||
bundle "install --gemfile='#{bundled_app}/Gemfile'", dir: bundled_app.parent
|
||||
expect(out).to include("installed into `./bundled_app/vendor/bundle`")
|
||||
expect(bundled_app("vendor/bundle")).to be_directory
|
||||
expect(the_bundle).to include_gems "myrack 1.0.0"
|
||||
end
|
||||
|
||||
it "installs the bundle relatively to current working directory" do
|
||||
bundle "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle", dir: bundled_app.parent
|
||||
expect(out).to include("installed into `./vendor/bundle`")
|
||||
expect(bundled_app("../vendor/bundle")).to be_directory
|
||||
expect(the_bundle).to include_gems "myrack 1.0.0"
|
||||
end
|
||||
it "installs the bundle relatively to repository root, when Bundler run from a different directory" do
|
||||
bundle "config path vendor/bundle", dir: bundled_app
|
||||
bundle "install --gemfile='#{bundled_app}/Gemfile'", dir: bundled_app.parent
|
||||
expect(out).to include("installed into `./bundled_app/vendor/bundle`")
|
||||
expect(bundled_app("vendor/bundle")).to be_directory
|
||||
expect(the_bundle).to include_gems "myrack 1.0.0"
|
||||
end
|
||||
|
||||
it "installs the standalone bundle relative to the cwd" do
|
||||
bundle :install, gemfile: bundled_app_gemfile, standalone: true, dir: bundled_app.parent
|
||||
expect(out).to include("installed into `./bundled_app/bundle`")
|
||||
expect(bundled_app("bundle")).to be_directory
|
||||
expect(bundled_app("bundle/ruby")).to be_directory
|
||||
it "installs the bundle relatively to Gemfile folder, when repository root can't be inferred from settings" do
|
||||
bundle "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle", dir: bundled_app.parent
|
||||
expect(out).to include("installed into `./bundled_app/vendor/bundle`")
|
||||
expect(bundled_app("vendor/bundle")).to be_directory
|
||||
expect(the_bundle).to include_gems "myrack 1.0.0"
|
||||
end
|
||||
|
||||
bundle "config unset path"
|
||||
it "installs the standalone bundle relative to the cwd" do
|
||||
bundle :install, gemfile: bundled_app_gemfile, standalone: true, dir: bundled_app.parent
|
||||
expect(out).to include("installed into `./bundled_app/bundle`")
|
||||
expect(bundled_app("bundle")).to be_directory
|
||||
expect(bundled_app("bundle/ruby")).to be_directory
|
||||
|
||||
bundle :install, gemfile: bundled_app_gemfile, standalone: true, dir: bundled_app("subdir").tap(&:mkpath)
|
||||
expect(out).to include("installed into `../bundle`")
|
||||
expect(bundled_app("bundle")).to be_directory
|
||||
expect(bundled_app("bundle/ruby")).to be_directory
|
||||
end
|
||||
bundle "config unset path"
|
||||
|
||||
bundle :install, gemfile: bundled_app_gemfile, standalone: true, dir: bundled_app("subdir").tap(&:mkpath)
|
||||
expect(out).to include("installed into `../bundle`")
|
||||
expect(bundled_app("bundle")).to be_directory
|
||||
expect(bundled_app("bundle/ruby")).to be_directory
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue