Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Merge #7393
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bundlerbot and andrehjr committed Nov 6, 2019
2 parents a7cc4ec + 293ad80 commit f83412a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/bundler/cli/add.rb
Expand Up @@ -21,6 +21,7 @@ def run

def perform_bundle_install
Installer.install(Bundler.root, Bundler.definition)
Bundler.load.cache if Bundler.app_cache.exist?
end

def inject_dependencies
Expand Down
9 changes: 9 additions & 0 deletions spec/commands/add_spec.rb
Expand Up @@ -239,4 +239,13 @@
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

0 comments on commit f83412a

Please sign in to comment.