diff --git a/lib/bundler.rb b/lib/bundler.rb index beac9f1dff3..82182d30eb2 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -430,7 +430,7 @@ def load_gemspec(file, validate = false) def load_gemspec_uncached(file, validate = false) path = Pathname.new(file) - contents = read_file(file) + contents = File.open(file, "r:UTF-8", &:read) 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 5b6778bdd4f..ef5e8e90e61 100644 --- a/spec/install/gemspecs_spec.rb +++ b/spec/install/gemspecs_spec.rb @@ -63,6 +63,33 @@ expect(out).to include("Bundle complete!") end + it "reads gemspecs respecting their encoding" do + skip "unicode constants are most likely not supported on 1.8" if RUBY_VERSION < "1.9" + + create_file("version.rb", <<-RUBY) + module Persistent💎 + VERSION = "0.0.1" + end + RUBY + + create_file("persistent-dmnd.gemspec", <<-G) + require_relative "version" + + Gem::Specification.new do |gem| + gem.name = "persistent-dmnd" + gem.version = Persistent💎::VERSION + gem.author = "Ivo Anjo" + gem.summary = "Unscratchable stuff" + end + G + + install_gemfile <<-G + 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|