summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-11-06 09:34:09 +0000
committerBundlerbot <bot@bundler.io>2019-11-06 09:34:09 +0000
commitf83412ae8cda9c933b8cf33ec2abfb78a408daab (patch)
tree48b7b883fd98ae33dfccbb5f4b42bb5d863e16bf
parenta7cc4ec87f17e549a1f0fb9063c53a76889426d6 (diff)
parent293ad80da8939f766fe886c7653903f09b6133d8 (diff)
downloadbundler-f83412ae8cda9c933b8cf33ec2abfb78a408daab.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>
-rw-r--r--lib/bundler/cli/add.rb1
-rw-r--r--spec/commands/add_spec.rb9
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