From 0646f9e286ff330a227cea01812b1ead4fa601cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 17 Jun 2019 13:17:54 +0200 Subject: [PATCH] Use real paths for `bundle clean` --- lib/bundler/definition.rb | 2 +- spec/commands/clean_spec.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 76950ff96a0..4664eec24df 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -317,7 +317,7 @@ def has_local_dependencies? end def spec_git_paths - sources.git_sources.map {|s| s.path.to_s } + sources.git_sources.map {|s| File.realpath(s.path) } end def groups diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 0053947c859..a3bbe9f01f3 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -183,6 +183,32 @@ def should_not_have_gems(*gems) expect(vendored_gems("bin/rackup")).to exist end + it "keeps used git gems even if installed to a symlinked location" do + build_git "foo", :path => lib_path("foo") + git_path = lib_path("foo") + revision = revision_for(git_path) + + gemfile <<-G + source "file://#{gem_repo1}" + + gem "rack", "1.0.0" + git "#{git_path}", :ref => "#{revision}" do + gem "foo" + end + G + + FileUtils.mkdir_p(bundled_app("real-path")) + FileUtils.ln_sf(bundled_app("real-path"), bundled_app("symlink-path")) + + bundle "install", forgotten_command_line_options(:path => bundled_app("symlink-path")) + + bundle :clean + + expect(out).not_to include("Removing foo (#{revision[0..11]})") + + expect(bundled_app("symlink-path/#{Bundler.ruby_scope}/bundler/gems/foo-#{revision[0..11]}")).to exist + end + it "removes old git gems" do build_git "foo-bar", :path => lib_path("foo-bar") revision = revision_for(lib_path("foo-bar"))