Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit ea4926a

Browse files
committed
Auto merge of #5436 - okkez:fix-frozen-string-literal-error-with-rubygems-2.6.8, r=segiddins
Use empty array when `spec_settings` returns `nil` If use bundler 1.14.4 with rubygems 2.6.8 and `Bundler.settings["build.#{spec.name}"]` returns `nil` then we get error "can't modify frozen literal string" from [rubygems](https://github.com/rubygems/rubygems/blob/v2.6.8/lib/rubygems/ext/rake_builder.rb#L13). RubyGems 2.6.8 is the default version for Ruby2.4.0. See also ku1ik/rainbow#48
2 parents d8e009d + 65a5271 commit ea4926a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/bundler/installer/gem_installer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def spec_settings
5252
end
5353

5454
def install
55-
spec.source.install(spec, :force => force, :ensure_builtin_gems_cached => standalone, :build_args => [spec_settings])
55+
spec.source.install(spec, :force => force, :ensure_builtin_gems_cached => standalone, :build_args => Array(spec_settings))
5656
end
5757

5858
def install_with_settings
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# frozen_string_literal: true
2+
require "spec_helper"
3+
require "bundler/installer/gem_installer"
4+
5+
RSpec.describe Bundler::GemInstaller do
6+
let(:installer) { instance_double("Installer") }
7+
let(:spec_source) { instance_double("SpecSource") }
8+
let(:spec) { instance_double("Specification", :name => "dummy", :version => "0.0.1", :loaded_from => "dummy", :source => spec_source) }
9+
10+
subject { described_class.new(spec, installer) }
11+
12+
context "spec_settings is nil" do
13+
it "invokes install method with empty build_args", :rubygems => ">= 2" do
14+
allow(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => [])
15+
subject.install_from_spec
16+
end
17+
end
18+
19+
context "spec_settings is build option" do
20+
it "invokes install method with build_args", :rubygems => ">= 2" do
21+
allow(Bundler.settings).to receive(:[]).with(:bin)
22+
allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy")
23+
allow(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy"])
24+
subject.install_from_spec
25+
end
26+
end
27+
end

0 commit comments

Comments
 (0)