summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-07-02 09:31:47 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-07-07 11:53:11 +0900
commitcd3389e5c25489e426b891ea673a483fdca1b2ce (patch)
tree038d685c447b77af1505d21c112982587e5ca6d1
parent5fa484a4418e0e38a2d871e9a6f9ac921522e1e9 (diff)
[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. https://github.com/rubygems/rubygems/commit/6f520eb146
-rw-r--r--lib/bundler/cli/install.rb4
-rw-r--r--lib/bundler/feature_flag.rb1
-rw-r--r--lib/bundler/man/bundle-config.13
-rw-r--r--lib/bundler/man/bundle-config.1.ronn2
-rw-r--r--lib/bundler/settings.rb1
-rw-r--r--lib/bundler/settings/validator.rb23
-rw-r--r--spec/bundler/install/path_spec.rb52
7 files changed, 33 insertions, 53 deletions
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 94d485682d..c31be40e55 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -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"]
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index efd128139a..35390edc6c 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -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? }
diff --git a/lib/bundler/man/bundle-config.1 b/lib/bundler/man/bundle-config.1
index 4628a885f0..04c0bffcee 100644
--- a/lib/bundler/man/bundle-config.1
+++ b/lib/bundler/man/bundle-config.1
@@ -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
diff --git a/lib/bundler/man/bundle-config.1.ronn b/lib/bundler/man/bundle-config.1.ronn
index 10ede264b0..928a34297f 100644
--- a/lib/bundler/man/bundle-config.1.ronn
+++ b/lib/bundler/man/bundle-config.1.ronn
@@ -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):
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index f0c8448b8b..b24cd4795f 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -34,7 +34,6 @@ module Bundler
lockfile_checksums
no_install
no_prune
- path_relative_to_cwd
path.system
plugins
prefer_patch
diff --git a/lib/bundler/settings/validator.rb b/lib/bundler/settings/validator.rb
index 0a57ea7f03..9aa1627fb2 100644
--- a/lib/bundler/settings/validator.rb
+++ b/lib/bundler/settings/validator.rb
@@ -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
diff --git a/spec/bundler/install/path_spec.rb b/spec/bundler/install/path_spec.rb
index 92bb158958..0ede8df8ff 100644
--- a/spec/bundler/install/path_spec.rb
+++ b/spec/bundler/install/path_spec.rb
@@ -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 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 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 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