diff options
Diffstat (limited to 'lib/rubygems.rb')
-rw-r--r-- | lib/rubygems.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 89f718da24..914204858c 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -187,9 +187,28 @@ module Gem path = path.dup.untaint if path == "-" - path = GEM_DEP_FILES.find { |f| File.exists?(f) } + here = Dir.pwd + start = here - return unless path + begin + while true + path = GEM_DEP_FILES.find { |f| File.exists?(f) } + + if path + path = File.join here, path + break + end + + Dir.chdir ".." + + # If we're at a toplevel, stop. + return if Dir.pwd == here + + here = Dir.pwd + end + ensure + Dir.chdir start + end end return unless File.exists? path |