diff options
author | The Bundler Bot <bot@bundler.io> | 2018-04-08 20:07:53 +0000 |
---|---|---|
committer | Colby Swandale <me@colby.fyi> | 2018-04-20 10:28:36 +1000 |
commit | 42068499ac247317fe85daae1f148593a71a1701 (patch) | |
tree | 54f9a0ea6ef885340db5ca52d50e0e16609cd43b | |
parent | 04820bd77bb55ddf78f64608749b197f72aa0471 (diff) | |
download | bundler-42068499ac247317fe85daae1f148593a71a1701.tar.gz |
Auto merge of #6480 - bundler:segiddins/6475-install-path-dot, r=indirect
[Source::RubyGems] Allow installing when the path is `.`
### What was the end-user problem that led to this PR?
The problem was `bundle install` would fail when the path was configured to be the current working directory.
Fixes #6475.
### What was your diagnosis of the problem?
My diagnosis was `Gem::RemoteFetcher` caches `.gem` files differently when `Dir.pwd == download_dir`
### What is your fix for the problem, implemented in this PR?
My fix moves the file rubygems has downloaded to the cache directory we expect.
### Why did you choose this fix out of the possible options?
I chose this fix because it does not re-implement logic in rubygems, and it keeps the directory structure bundler generates consistent.
(cherry picked from commit ba49ed283fa20d313f95cdefcd32f8f82a786c9f)
-rw-r--r-- | lib/bundler/source/rubygems.rb | 5 | ||||
-rw-r--r-- | spec/install/path_spec.rb | 12 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index cd37f8cfc6..30e89d2292 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -479,7 +479,10 @@ module Bundler else uri = spec.remote.uri Bundler.ui.confirm("Fetching #{version_message(spec)}") - Bundler.rubygems.download_gem(spec, uri, download_path) + rubygems_local_path = Bundler.rubygems.download_gem(spec, uri, download_path) + if rubygems_local_path != local_path + FileUtils.mv(rubygems_local_path, local_path) + end cache_globally(spec, local_path) end end diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb index fb356899a6..3fce72b78e 100644 --- a/spec/install/path_spec.rb +++ b/spec/install/path_spec.rb @@ -67,7 +67,7 @@ RSpec.describe "bundle install" do if type == :env ENV["BUNDLE_PATH"] = location elsif type == :global - bundle "config path #{location}", "no-color" => nil + bundle! "config path #{location}", "no-color" => nil end end @@ -81,6 +81,16 @@ RSpec.describe "bundle install" do expect(the_bundle).to include_gems "rack 1.0.0" end + it "installs gems to ." do + set_bundle_path(type, ".") + bundle! "config --global disable_shared_gems true" + + bundle! :install + + expect([bundled_app("cache/rack-1.0.0.gem"), bundled_app("gems/rack-1.0.0"), bundled_app("specifications/rack-1.0.0.gemspec")]).to all exist + expect(the_bundle).to include_gems "rack 1.0.0" + end + it "installs gems to BUNDLE_PATH with #{type}" do set_bundle_path(type, bundled_app("vendor").to_s) |