summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2016-12-24 20:30:09 +0000
committerThe Bundler Bot <bot@bundler.io>2016-12-24 20:30:09 +0000
commit44dc252655d89f8ac601a4758f0571a3629bbfe0 (patch)
tree3a0d0bce05ca6ef4c87aef76535e90b7f0b8ab39
parent857168ed707027c8c4eb913c25425dad8a4b0e11 (diff)
parent235e5d3eca1f16886a16d06a7a26b7294e3a18e8 (diff)
downloadbundler-44dc252655d89f8ac601a4758f0571a3629bbfe0.tar.gz
Auto merge of #5023 - renuo:4854-gemnotfound-error, r=segiddins
4854 gemnotfound error Fixes broken test Wanting to help out, I was on the outlook for something easy to fix in bundler. I stumbled upon this issue #4854, which was already tackled by @b-ggs but somehow not merged yet. I went on to check whether I could do something. Here's what I've come up with: @b-ggs' PR included everything to solve the issue, but introduced the use of `Bundler.app_cache` in the resolver. This works out just fine until you run `bundle plugin install`, which does not seem to require a Gemfile. `Bundler.app_cache` however calls `root`, which then again tries to find a Gemfile. This obviously fails and raises a `GemfileNotFound` exception. The error message "Could not locate Gemfile or .bundle/ directory" starts very similar to the one expected in the failing test ("Could not find"). This however, is a completely different error. The solution is now is to rescue the GemfileNotFound error when it comes up to here. All credit for solving the issue goes to @b-ggs and his PR here: https://github.com/bundler/bundler/pull/4865
-rw-r--r--lib/bundler/resolver.rb7
-rw-r--r--spec/commands/exec_spec.rb2
-rw-r--r--spec/commands/lock_spec.rb2
-rw-r--r--spec/install/post_bundle_message_spec.rb17
4 files changed, 24 insertions, 4 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index b8016b37a9..bdb8f4883c 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -365,8 +365,13 @@ module Bundler
"Source does not contain any versions of '#{requirement}'"
end
else
+ cache_message = begin
+ " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
+ rescue GemfileNotFound
+ nil
+ end
message = "Could not find gem '#{requirement}' in any of the gem sources " \
- "listed in your Gemfile or available on this machine."
+ "listed in your Gemfile#{cache_message}."
end
raise GemNotFound, message
end
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index 5d1a63e680..cb4daa46bb 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -555,7 +555,7 @@ describe "bundle exec" do
let(:exit_code) { Bundler::GemNotFound.new.status_code }
let(:expected) { <<-EOS.strip }
-\e[31mCould not find gem 'rack (= 2)' in any of the gem sources listed in your Gemfile or available on this machine.\e[0m
+\e[31mCould not find gem 'rack (= 2)' in any of the gem sources listed in your Gemfile.\e[0m
\e[33mRun `bundle install` to install missing gems.\e[0m
EOS
diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb
index b51003f257..52dfa23b3d 100644
--- a/spec/commands/lock_spec.rb
+++ b/spec/commands/lock_spec.rb
@@ -87,7 +87,7 @@ describe "bundle lock" do
it "does not fetch remote specs when using the --local option" do
bundle "lock --update --local"
- expect(out).to include("available on this machine.")
+ expect(out).to include("sources listed in your Gemfile")
end
it "writes to a custom location using --lockfile" do
diff --git a/spec/install/post_bundle_message_spec.rb b/spec/install/post_bundle_message_spec.rb
index 10c71f0a51..7e2eacfb90 100644
--- a/spec/install/post_bundle_message_spec.rb
+++ b/spec/install/post_bundle_message_spec.rb
@@ -104,7 +104,22 @@ describe "post bundle message" do
gem "rack"
gem "not-a-gem", :group => :development
G
- expect(out).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile or available on this machine.")
+ expect(out).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile.")
+ end
+
+ it "should report a helpful error message with reference to cache if available" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ bundle :cache
+ expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ gem "not-a-gem", :group => :development
+ G
+ expect(out).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile or in gems cached in vendor/cache.")
end
end
end