diff --git a/lib/bundler/cli/add.rb b/lib/bundler/cli/add.rb index 7c6235f17c4..9a71a149b14 100644 --- a/lib/bundler/cli/add.rb +++ b/lib/bundler/cli/add.rb @@ -21,6 +21,7 @@ def run def perform_bundle_install Installer.install(Bundler.root, Bundler.definition) + Bundler.load.cache if Bundler.app_cache.exist? && !Bundler.frozen_bundle? end def inject_dependencies diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb index fdfca5d8f24..482e140b84d 100644 --- a/spec/commands/add_spec.rb +++ b/spec/commands/add_spec.rb @@ -239,4 +239,14 @@ 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_all is true" do + it "caches all new dependencies added for the specified gem" do + bundle "config set cache_all true" + bundle! :package + + bundle "add 'rack' --version=1.0.0" + expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist + end + end end