summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2018-01-30 20:30:31 -0300
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2018-01-31 08:48:06 -0300
commit6466c78c750399740069865337f8189d75e259ea (patch)
treebc6e8c0acb029cc1130ebcc099802de6d03e3d0a
parentfe9d6989a11443dbfe1840cc07f89918e3d7b37d (diff)
downloadbundler-6466c78c750399740069865337f8189d75e259ea.tar.gz
Fix hang when gemspec has incompatible encoding
Not sure about the reason, but binary read fixes it...
-rw-r--r--lib/bundler.rb2
-rw-r--r--spec/install/gemspecs_spec.rb17
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 63ae335ac6..e559ad3d18 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -441,7 +441,7 @@ EOF
def load_gemspec_uncached(file, validate = false)
path = Pathname.new(file)
- contents = path.read
+ contents = path.binread
spec = if contents.start_with?("---") # YAML header
eval_yaml_gemspec(path, contents)
else
diff --git a/spec/install/gemspecs_spec.rb b/spec/install/gemspecs_spec.rb
index 0c1ed99097..5dca6f68c0 100644
--- a/spec/install/gemspecs_spec.rb
+++ b/spec/install/gemspecs_spec.rb
@@ -46,6 +46,23 @@ RSpec.describe "bundle install" do
expect(the_bundle).to include_gems "activesupport 2.3.2"
end
+ it "does not hang when gemspec has incompatible encoding" do
+ create_file("foo.gemspec", <<-G)
+ Gem::Specification.new do |gem|
+ gem.name = "pry-byebug"
+ gem.version = "3.4.2"
+ gem.author = "David Rodríguez"
+ gem.summary = "Good stuff"
+ end
+ G
+
+ install_gemfile <<-G, :env => { "LANG" => "C" }
+ gemspec
+ G
+
+ expect(out).to include("Bundle complete!")
+ end
+
context "when ruby version is specified in gemspec and gemfile" do
it "installs when patch level is not specified and the version matches" do
build_lib("foo", :path => bundled_app) do |s|