summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2012-11-26 07:33:21 -0600
committerBen Woosley <ben.woosley@gmail.com>2012-11-26 07:33:21 -0600
commitbfd7280db05f8d19e7c5a4fd1c044799524aafc0 (patch)
tree6d4ba153db2a6f63103947fe5f26059b5897fc13
parent4680712be12c1aa982f163353c300ec564b7f797 (diff)
downloadbundler-bfd7280db05f8d19e7c5a4fd1c044799524aafc0.tar.gz
Because required files can sometimes themselves contain unrelated LoadErrors (e.g. during inter-gem development), run the regexps against the LoadError before the namespaced fallback check.
-rw-r--r--lib/bundler/runtime.rb6
-rw-r--r--spec/runtime/require_spec.rb22
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index db6f21d698..d4a432454b 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -68,6 +68,9 @@ module Bundler
Kernel.require file
end
rescue LoadError => e
+ REGEXPS.find { |r| r =~ e.message }
+ raise if dep.autorequire || $1 != required_file
+
if dep.autorequire.nil? && dep.name.include?('-')
begin
namespaced_file = dep.name.gsub('-', '/')
@@ -78,9 +81,6 @@ module Bundler
raise if dep.autorequire || (regex_name && regex_name.gsub('-', '/') != namespaced_file)
raise e if regex_name.nil?
end
- else
- REGEXPS.find { |r| r =~ e.message }
- raise if dep.autorequire || $1 != required_file
end
end
end
diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb
index 349696606b..db72ff70f0 100644
--- a/spec/runtime/require_spec.rb
+++ b/spec/runtime/require_spec.rb
@@ -158,6 +158,28 @@ describe "Bundler.require" do
expect(err).to eq("ZOMG LOAD ERROR")
end
+
+ it "doesn't swallow the error when the library has an unrelated error" do
+ build_lib "load-fuuu", "1.0.0" do |s|
+ s.write "lib/load-fuuu.rb", "raise LoadError.new(\"cannot load such file -- load-bar\")"
+ end
+
+ gemfile <<-G
+ path "#{lib_path}"
+ gem "load-fuuu"
+ G
+
+ cmd = <<-RUBY
+ begin
+ Bundler.require
+ rescue LoadError => e
+ $stderr.puts "ZOMG LOAD ERROR: \#{e.message}"
+ end
+ RUBY
+ run(cmd, :expect_err => true)
+
+ expect(err).to eq("ZOMG LOAD ERROR: cannot load such file -- load-bar")
+ end
end
describe "using bundle exec" do