Skip to content

Commit cd3389e

Browse files
deivid-rodriguezhsbt
authored andcommitted
[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. ruby/rubygems@6f520eb146
1 parent 5fa484a commit cd3389e

File tree

7 files changed

+33
-53
lines changed

7 files changed

+33
-53
lines changed

lib/bundler/cli/install.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ def normalize_settings
160160
Bundler.settings.set_command_option_if_given :path, options[:path]
161161

162162
if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
163-
Bundler.settings.temporary(path_relative_to_cwd: false) do
164-
Bundler.settings.set_command_option :path, "bundle"
165-
end
163+
Bundler.settings.set_command_option :path, "bundle"
166164
end
167165

168166
bin_option = options["binstubs"]

lib/bundler/feature_flag.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def self.settings_method(name, key, &default)
3232
settings_flag(:forget_cli_options) { bundler_4_mode? }
3333
settings_flag(:global_gem_cache) { bundler_4_mode? }
3434
settings_flag(:lockfile_checksums) { bundler_4_mode? }
35-
settings_flag(:path_relative_to_cwd) { bundler_4_mode? }
3635
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
3736
settings_flag(:setup_makes_kernel_gem_public) { !bundler_4_mode? }
3837
settings_flag(:update_requires_all_flag) { bundler_5_mode? }

lib/bundler/man/bundle-config.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ The location on disk where all gems in your bundle will be located regardless of
146146
\fBpath\.system\fR (\fBBUNDLE_PATH__SYSTEM\fR)
147147
Whether Bundler will install gems into the default system path (\fBGem\.dir\fR)\.
148148
.TP
149-
\fBpath_relative_to_cwd\fR (\fBBUNDLE_PATH_RELATIVE_TO_CWD\fR)
150-
Makes \fB\-\-path\fR relative to the CWD instead of the \fBGemfile\fR\.
151-
.TP
152149
\fBplugins\fR (\fBBUNDLE_PLUGINS\fR)
153150
Enable Bundler's experimental plugin system\.
154151
.TP

lib/bundler/man/bundle-config.1.ronn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
168168
before Bundler 4.
169169
* `path.system` (`BUNDLE_PATH__SYSTEM`):
170170
Whether Bundler will install gems into the default system path (`Gem.dir`).
171-
* `path_relative_to_cwd` (`BUNDLE_PATH_RELATIVE_TO_CWD`):
172-
Makes `--path` relative to the CWD instead of the `Gemfile`.
173171
* `plugins` (`BUNDLE_PLUGINS`):
174172
Enable Bundler's experimental plugin system.
175173
* `prefer_patch` (BUNDLE_PREFER_PATCH):

lib/bundler/settings.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class Settings
3434
lockfile_checksums
3535
no_install
3636
no_prune
37-
path_relative_to_cwd
3837
path.system
3938
plugins
4039
prefer_patch

lib/bundler/settings/validator.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,6 @@ def self.validate!(key, value, settings)
7474
fail!(key, value, "`#{other_key}` is current set to #{other_setting.inspect}", "the `#{conflicting.join("`, `")}` groups conflict")
7575
end
7676
end
77-
78-
rule %w[path], "relative paths are expanded relative to the current working directory" do |key, value, settings|
79-
next if value.nil?
80-
81-
path = Pathname.new(value)
82-
next if !path.relative? || !Bundler.feature_flag.path_relative_to_cwd?
83-
84-
path = path.expand_path
85-
86-
root = begin
87-
Bundler.root
88-
rescue GemfileNotFound
89-
Pathname.pwd.expand_path
90-
end
91-
92-
path = begin
93-
path.relative_path_from(root)
94-
rescue ArgumentError
95-
path
96-
end
97-
98-
set(settings, key, path.to_s)
99-
end
10077
end
10178
end
10279
end

spec/bundler/install/path_spec.rb

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,41 @@
5959
expect(the_bundle).to include_gems "myrack 1.0.0"
6060
end
6161

62-
context "with path_relative_to_cwd set to true" do
63-
before { bundle "config set path_relative_to_cwd true" }
64-
65-
it "installs the bundle relatively to current working directory" do
66-
bundle "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle", dir: bundled_app.parent
67-
expect(out).to include("installed into `./vendor/bundle`")
68-
expect(bundled_app("../vendor/bundle")).to be_directory
69-
expect(the_bundle).to include_gems "myrack 1.0.0"
70-
end
62+
it "installs the bundle relatively to repository root, when Bundler run from the same directory" do
63+
bundle "config path vendor/bundle", dir: bundled_app.parent
64+
bundle "install --gemfile='#{bundled_app}/Gemfile'", dir: bundled_app.parent
65+
expect(out).to include("installed into `./bundled_app/vendor/bundle`")
66+
expect(bundled_app("vendor/bundle")).to be_directory
67+
expect(the_bundle).to include_gems "myrack 1.0.0"
68+
end
69+
70+
it "installs the bundle relatively to repository root, when Bundler run from a different directory" do
71+
bundle "config path vendor/bundle", dir: bundled_app
72+
bundle "install --gemfile='#{bundled_app}/Gemfile'", dir: bundled_app.parent
73+
expect(out).to include("installed into `./bundled_app/vendor/bundle`")
74+
expect(bundled_app("vendor/bundle")).to be_directory
75+
expect(the_bundle).to include_gems "myrack 1.0.0"
76+
end
7177

72-
it "installs the standalone bundle relative to the cwd" do
73-
bundle :install, gemfile: bundled_app_gemfile, standalone: true, dir: bundled_app.parent
74-
expect(out).to include("installed into `./bundled_app/bundle`")
75-
expect(bundled_app("bundle")).to be_directory
76-
expect(bundled_app("bundle/ruby")).to be_directory
78+
it "installs the bundle relatively to Gemfile folder, when repository root can't be inferred from settings" do
79+
bundle "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle", dir: bundled_app.parent
80+
expect(out).to include("installed into `./bundled_app/vendor/bundle`")
81+
expect(bundled_app("vendor/bundle")).to be_directory
82+
expect(the_bundle).to include_gems "myrack 1.0.0"
83+
end
7784

78-
bundle "config unset path"
85+
it "installs the standalone bundle relative to the cwd" do
86+
bundle :install, gemfile: bundled_app_gemfile, standalone: true, dir: bundled_app.parent
87+
expect(out).to include("installed into `./bundled_app/bundle`")
88+
expect(bundled_app("bundle")).to be_directory
89+
expect(bundled_app("bundle/ruby")).to be_directory
7990

80-
bundle :install, gemfile: bundled_app_gemfile, standalone: true, dir: bundled_app("subdir").tap(&:mkpath)
81-
expect(out).to include("installed into `../bundle`")
82-
expect(bundled_app("bundle")).to be_directory
83-
expect(bundled_app("bundle/ruby")).to be_directory
84-
end
91+
bundle "config unset path"
92+
93+
bundle :install, gemfile: bundled_app_gemfile, standalone: true, dir: bundled_app("subdir").tap(&:mkpath)
94+
expect(out).to include("installed into `../bundle`")
95+
expect(bundled_app("bundle")).to be_directory
96+
expect(bundled_app("bundle/ruby")).to be_directory
8597
end
8698
end
8799

0 commit comments

Comments
 (0)