mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[bundler/bundler] Merge #7340
7340: Fix bundle clean issue r=deivid-rodriguez a=deivid-rodriguez
### What was the end-user problem that led to this PR?
The problem was that `bundle clean` is crashing under some conditions.
### What was your diagnosis of the problem?
My diagnosis was that sometimes (when the bundle includes git sourced gems with extensions), it assumes that some paths exist, but they don't.
### What is your fix for the problem, implemented in this PR?
My fix is to ignore those paths.
### Why did you choose this fix out of the possible options?
I chose this fix because it fixes the issue.
Fixes #7338.
Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
(cherry picked from commit b007fde67c77c1f15f13b97eda186644c2a2be04)
3766053507
This commit is contained in:
parent
e6ad9452b6
commit
434af7303c
2 changed files with 92 additions and 28 deletions
|
@ -317,7 +317,7 @@ module Bundler
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec_git_paths
|
def spec_git_paths
|
||||||
sources.git_sources.map {|s| File.realpath(s.path) }
|
sources.git_sources.map {|s| File.realpath(s.path) if File.exist?(s.path) }.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def groups
|
def groups
|
||||||
|
|
|
@ -25,7 +25,9 @@ RSpec.describe "bundle clean" do
|
||||||
gem "foo"
|
gem "foo"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set clean false"
|
||||||
|
bundle! "install"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -52,7 +54,9 @@ RSpec.describe "bundle clean" do
|
||||||
gem "foo"
|
gem "foo"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set clean false"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -80,7 +84,9 @@ RSpec.describe "bundle clean" do
|
||||||
gem "foo"
|
gem "foo"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set clean false"
|
||||||
|
bundle! "install"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -111,8 +117,10 @@ RSpec.describe "bundle clean" do
|
||||||
end
|
end
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
bundle "install", forgotten_command_line_options(:without => "test_group")
|
bundle "install"
|
||||||
|
bundle "config set without test_group"
|
||||||
|
bundle "install"
|
||||||
bundle :clean
|
bundle :clean
|
||||||
|
|
||||||
expect(out).to include("Removing rack (1.0.0)")
|
expect(out).to include("Removing rack (1.0.0)")
|
||||||
|
@ -137,7 +145,8 @@ RSpec.describe "bundle clean" do
|
||||||
end
|
end
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
bundle :clean
|
bundle :clean
|
||||||
|
|
||||||
|
@ -160,7 +169,8 @@ RSpec.describe "bundle clean" do
|
||||||
end
|
end
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -200,7 +210,8 @@ RSpec.describe "bundle clean" do
|
||||||
FileUtils.mkdir_p(bundled_app("real-path"))
|
FileUtils.mkdir_p(bundled_app("real-path"))
|
||||||
FileUtils.ln_sf(bundled_app("real-path"), bundled_app("symlink-path"))
|
FileUtils.ln_sf(bundled_app("real-path"), bundled_app("symlink-path"))
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => bundled_app("symlink-path"))
|
bundle "config set path #{bundled_app("symlink-path")}"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
bundle :clean
|
bundle :clean
|
||||||
|
|
||||||
|
@ -222,7 +233,8 @@ RSpec.describe "bundle clean" do
|
||||||
end
|
end
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle! "install"
|
||||||
|
|
||||||
update_git "foo", :path => lib_path("foo-bar")
|
update_git "foo", :path => lib_path("foo-bar")
|
||||||
revision2 = revision_for(lib_path("foo-bar"))
|
revision2 = revision_for(lib_path("foo-bar"))
|
||||||
|
@ -252,7 +264,8 @@ RSpec.describe "bundle clean" do
|
||||||
gem "activesupport", :git => "#{lib_path("rails")}", :ref => '#{revision}'
|
gem "activesupport", :git => "#{lib_path("rails")}", :ref => '#{revision}'
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "install"
|
||||||
bundle :clean
|
bundle :clean
|
||||||
expect(out).to include("")
|
expect(out).to include("")
|
||||||
|
|
||||||
|
@ -274,7 +287,9 @@ RSpec.describe "bundle clean" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
G
|
G
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :without => "test")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set without test"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
bundle :clean
|
bundle :clean
|
||||||
|
|
||||||
|
@ -295,7 +310,9 @@ RSpec.describe "bundle clean" do
|
||||||
end
|
end
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :without => "development")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set without development"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
bundle :clean
|
bundle :clean
|
||||||
expect(exitstatus).to eq(0) if exitstatus
|
expect(exitstatus).to eq(0) if exitstatus
|
||||||
|
@ -324,7 +341,8 @@ RSpec.describe "bundle clean" do
|
||||||
gem "foo"
|
gem "foo"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -372,7 +390,9 @@ RSpec.describe "bundle clean" do
|
||||||
gem "thin"
|
gem "thin"
|
||||||
gem "rack"
|
gem "rack"
|
||||||
G
|
G
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => true)
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set clean false"
|
||||||
|
bundle "install --clean true"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -393,7 +413,9 @@ RSpec.describe "bundle clean" do
|
||||||
|
|
||||||
gem "foo"
|
gem "foo"
|
||||||
G
|
G
|
||||||
bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => true)
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set clean false"
|
||||||
|
bundle "install --clean true"
|
||||||
|
|
||||||
update_repo2 do
|
update_repo2 do
|
||||||
build_gem "foo", "1.0.1"
|
build_gem "foo", "1.0.1"
|
||||||
|
@ -436,7 +458,8 @@ RSpec.describe "bundle clean" do
|
||||||
gem "thin"
|
gem "thin"
|
||||||
gem "rack"
|
gem "rack"
|
||||||
G
|
G
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -456,7 +479,8 @@ RSpec.describe "bundle clean" do
|
||||||
|
|
||||||
gem "foo"
|
gem "foo"
|
||||||
G
|
G
|
||||||
bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle! "install"
|
||||||
|
|
||||||
update_repo2 do
|
update_repo2 do
|
||||||
build_gem "foo", "1.0.1"
|
build_gem "foo", "1.0.1"
|
||||||
|
@ -557,7 +581,8 @@ RSpec.describe "bundle clean" do
|
||||||
gem "foo", :git => "#{lib_path("foo-1.0")}"
|
gem "foo", :git => "#{lib_path("foo-1.0")}"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
# mimic 7 length git revisions in Gemfile.lock
|
# mimic 7 length git revisions in Gemfile.lock
|
||||||
gemfile_lock = File.read(bundled_app("Gemfile.lock")).split("\n")
|
gemfile_lock = File.read(bundled_app("Gemfile.lock")).split("\n")
|
||||||
|
@ -566,7 +591,8 @@ RSpec.describe "bundle clean" do
|
||||||
end
|
end
|
||||||
lockfile(bundled_app("Gemfile.lock"), gemfile_lock.join("\n"))
|
lockfile(bundled_app("Gemfile.lock"), gemfile_lock.join("\n"))
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
bundle :clean
|
bundle :clean
|
||||||
|
|
||||||
|
@ -616,7 +642,8 @@ RSpec.describe "bundle clean" do
|
||||||
gem "bar", "1.0", :path => "#{relative_path}"
|
gem "bar", "1.0", :path => "#{relative_path}"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "install"
|
||||||
bundle! :clean
|
bundle! :clean
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -628,7 +655,9 @@ RSpec.describe "bundle clean" do
|
||||||
gem "foo"
|
gem "foo"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set clean false"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -656,7 +685,9 @@ RSpec.describe "bundle clean" do
|
||||||
gem "foo"
|
gem "foo"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set clean false"
|
||||||
|
bundle "install"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -684,7 +715,9 @@ RSpec.describe "bundle clean" do
|
||||||
gem "foo"
|
gem "foo"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set clean false"
|
||||||
|
bundle "install"
|
||||||
bundle "config set dry_run false"
|
bundle "config set dry_run false"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
|
@ -714,7 +747,9 @@ RSpec.describe "bundle clean" do
|
||||||
gem "foo"
|
gem "foo"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle "config set clean false"
|
||||||
|
bundle! "install"
|
||||||
|
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{file_uri_for(gem_repo1)}"
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
@ -741,7 +776,8 @@ RSpec.describe "bundle clean" do
|
||||||
gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
|
gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle! "install"
|
||||||
expect(vendored_gems("bundler/gems/extensions")).to exist
|
expect(vendored_gems("bundler/gems/extensions")).to exist
|
||||||
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
|
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
|
||||||
|
|
||||||
|
@ -761,7 +797,8 @@ RSpec.describe "bundle clean" do
|
||||||
gem "simple_binary"
|
gem "simple_binary"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle! "install"
|
||||||
|
|
||||||
very_simple_binary_extensions_dir =
|
very_simple_binary_extensions_dir =
|
||||||
Pathname.glob("#{vendored_gems}/extensions/*/*/very_simple_binary-1.0").first
|
Pathname.glob("#{vendored_gems}/extensions/*/*/very_simple_binary-1.0").first
|
||||||
|
@ -800,7 +837,8 @@ RSpec.describe "bundle clean" do
|
||||||
gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
|
gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle! "install"
|
||||||
|
|
||||||
very_simple_binary_extensions_dir =
|
very_simple_binary_extensions_dir =
|
||||||
Pathname.glob("#{vendored_gems}/bundler/gems/extensions/*/*/very_simple_git_binary-1.0-#{short_revision}").first
|
Pathname.glob("#{vendored_gems}/bundler/gems/extensions/*/*/very_simple_git_binary-1.0-#{short_revision}").first
|
||||||
|
@ -825,4 +863,30 @@ RSpec.describe "bundle clean" do
|
||||||
|
|
||||||
expect(very_simple_binary_extensions_dir).not_to exist
|
expect(very_simple_binary_extensions_dir).not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "keeps git extension directories when excluded by group", :ruby_repo do
|
||||||
|
build_git "very_simple_git_binary", &:add_c_extension
|
||||||
|
|
||||||
|
revision = revision_for(lib_path("very_simple_git_binary-1.0"))
|
||||||
|
short_revision = revision[0..11]
|
||||||
|
|
||||||
|
gemfile <<-G
|
||||||
|
source "#{file_uri_for(gem_repo1)}"
|
||||||
|
|
||||||
|
group :development do
|
||||||
|
gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
|
||||||
|
end
|
||||||
|
G
|
||||||
|
|
||||||
|
bundle :lock
|
||||||
|
bundle "config set without development"
|
||||||
|
bundle "config set path vendor/bundle"
|
||||||
|
bundle! "install"
|
||||||
|
bundle! :clean
|
||||||
|
|
||||||
|
very_simple_binary_extensions_dir =
|
||||||
|
Pathname.glob("#{vendored_gems}/bundler/gems/extensions/*/*/very_simple_git_binary-1.0-#{short_revision}").first
|
||||||
|
|
||||||
|
expect(very_simple_binary_extensions_dir).to be_nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue