summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Steiner <diego.steiner@renuo.ch>2016-09-27 15:36:03 +0200
committerDiego Steiner <diego.steiner@renuo.ch>2016-09-27 16:01:08 +0200
commitb667f17fa2d86f4478b2b986f5613a07a94f3b3f (patch)
tree8d953818dd6813309640cb904e56a9088ff1983c
parentf809209b0c13a48a6da75692483bb51cf3ac0342 (diff)
downloadbundler-b667f17fa2d86f4478b2b986f5613a07a94f3b3f.tar.gz
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: bundler/bundler pull:4865 Fix rubocop offense
-rw-r--r--lib/bundler/resolver.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index e636e1f815..1dbe5b9921 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -250,6 +250,7 @@ module Bundler
end
def search_for(dependency)
+ puts "Searching for #{dependency}"
platform = dependency.__platform
dependency = dependency.dep unless dependency.is_a? Gem::Dependency
search = @search_for[dependency] ||= begin
@@ -365,7 +366,11 @@ module Bundler
"Source does not contain any versions of '#{requirement}'"
end
else
- cache_message = Bundler.app_cache.exist? ? " or in gems cached in vendor/cache" : ""
+ 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#{cache_message}."
end