diff options
author | Bundlerbot <bot@bundler.io> | 2019-11-06 09:34:09 +0000 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-11-07 16:41:44 +0100 |
commit | 184569535cb6ddc46558861e29050225d281c9a1 (patch) | |
tree | 10408b5a33b1a9dcadd61325e6e70754d9e7564f | |
parent | a56004c7456eabe7d8b6428e03657a949c4de638 (diff) | |
download | bundler-184569535cb6ddc46558861e29050225d281c9a1.tar.gz |
Merge #7393
7393: Make 'bundle add' cache newly added gems when needed r=deivid-rodriguez a=andrehjr
### What was the end-user problem that led to this PR?
The problem was that when calling `bundle add` with cache_all as true, I have to call an additional `bundle install` to vendor gems.
### What was your diagnosis of the problem?
My diagnosis was that a call to Bundler.load.cache was missing. For example Bundler::CLI::Update does the same after installing gems.
### What is your fix for the problem, implemented in this PR?
My fix was to call Bundler.load.cache when `Bundler.app_cache.exist? `
### Why did you choose this fix out of the possible options?
I chose this fix because it looks like this makes the behavior consistent with other commands.
I should also say that, as this is my first PR here, I'm not sure that this is the best solution, and it seems an easy fix for #7384.
Co-authored-by: André Luis Leal Cardoso Junior <andrehjr@gmail.com>
(cherry picked from commit f83412ae8cda9c933b8cf33ec2abfb78a408daab)
-rw-r--r-- | lib/bundler/cli/add.rb | 1 | ||||
-rw-r--r-- | spec/commands/add_spec.rb | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/bundler/cli/add.rb b/lib/bundler/cli/add.rb index 7c6235f17c..07b951f1ef 100644 --- a/lib/bundler/cli/add.rb +++ b/lib/bundler/cli/add.rb @@ -21,6 +21,7 @@ module Bundler def perform_bundle_install Installer.install(Bundler.root, Bundler.definition) + Bundler.load.cache if Bundler.app_cache.exist? end def inject_dependencies diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb index fdfca5d8f2..35fd43d3d2 100644 --- a/spec/commands/add_spec.rb +++ b/spec/commands/add_spec.rb @@ -239,4 +239,13 @@ RSpec.describe "bundle add" do expect(err).not_to include("You may also need to change the version requirement specified in the Gemfile if it's too restrictive") end end + + describe "when a gem is added and cache exists" do + it "caches all new dependencies added for the specified gem" do + bundle! :cache + + bundle "add 'rack' --version=1.0.0" + expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist + end + end end |