Permalink
Browse files

instructions for when OpenSSL is missing

  • Loading branch information...
1 parent e14d4e3 commit e84de5878e3e83388f546559eab17ead3750c906 @indirect indirect committed May 27, 2012
Showing with 44 additions and 0 deletions.
  1. +10 −0 lib/bundler/fetcher.rb
  2. +34 −0 spec/install/gems/dependency_api_spec.rb
View
@@ -104,6 +104,16 @@ def specs(gem_names, source)
end
index
+ rescue LoadError => e
+ if e.message.include?("cannot load such file -- openssl")
+ raise InstallError,
+ "\nCould not load OpenSSL." \
+ "\nYou must recompile Ruby with OpenSSL support or change the sources in your" \
+ "\nGemfile from 'https' to 'http'. Instructions for compiling with OpenSSL" \
+ "\nusing RVM are available at rvm.io/packages/openssl."
+ else
+ raise e
+ end
end
# fetch index
@@ -386,4 +386,38 @@
out.should_not include("#{user}:#{password}")
end
end
+
+ context "when ruby is compiled without openssl" do
+ before do
+ # Install a monkeypatch that reproduces the effects of openssl being
+ # missing when the fetcher runs, as happens in real life. The reason
+ # we can't just overwrite openssl.rb is that Artifice uses it.
+ bundled_app("broken_ssl").mkpath
+ bundled_app("broken_ssl/openssl.rb").open("w") do |f|
+ f.write <<-RUBY
+ $:.delete File.expand_path("..", __FILE__)
+ require 'openssl'
+
+ require 'bundler'
+ class Bundler::Fetcher
+ def fetch(*)
+ raise LoadError, "cannot load such file -- openssl"
+ end
+ end
+ RUBY
+ end
+ end
+
+ it "explains what to do to get it" do
+ gemfile <<-G
+ source "#{source_uri.gsub(/http/, 'https')}"
+ gem "rack"
+ G
+
+ bundle :install, :artifice => "endpoint",
+ :env => {"RUBYOPT" => "-I#{bundled_app("broken_ssl")}"}
+ out.should include("Could not load OpenSSL.")
+ end
+ end
+
end

0 comments on commit e84de58

Please sign in to comment.