-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RakeBuilder: avoid frozen string issue #1819
Conversation
- See 45966be which had this fix most everywhere else
The failure to build was one 1.8.7 with the text:
|
# | ||
# It should not fail with a non-empty args list either | ||
def test_class_build_with_args | ||
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a fair amount of duplication between this test-case and the one above. A meaningful one would be to extract would be this file creation. Especially since the two files are identical.
@teoljungberg There! It worked. |
@@ -12,16 +12,9 @@ def setup | |||
FileUtils.mkdir_p @ext | |||
FileUtils.mkdir_p @dest_path | |||
end | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably not be included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for careful reading, T.
- this avoids the reek warning Prima Donna Method; avoids confusing the reader
Good catch! |
📌 Commit cffb000 has been approved by |
RakeBuilder: avoid frozen string issue # Description: This PR adds a missing `#dup` ("convert frozen string literal to a mutable String object instance") in the same way that 45966be did. The problem only appears when there're `args` to `.build`. To trigger this behavior, I duplicated a test and added a variable with a non-empty array of an empty string (to have benign test data). **What it looks like without the fix** Without this change, the user's failure will look like this: ``` Gem::Ext::BuildError: ERROR: Failed to build gem native extension. can't modify frozen String, created at /home/travis/.rvm/rubies/jruby-9.1.7.0/lib/ruby/stdlib/rubygems/ext/rake_builder.rb:11 ``` **Reproduce** To reproduce the issue, write a `mkrf_conf.rb` which calls `build`. Here is an example `ext/mkrf_conf.rb` with a failing build: https://github.com/sickill/rainbow/blob/master/ext/mkrf_conf.rb # Tasks: - [x] Describe the problem / feature - [x] Write tests - [x] Write code to solve the problem - [x] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
💔 Test failed - status |
@segiddins The 1.8.7 picks wrong deps now and then. Don't know why. It works half the time. |
@@ -9,7 +9,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder | |||
|
|||
def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil) | |||
if File.basename(extension) =~ /mkrf_conf/i then | |||
cmd = "#{Gem.ruby} #{File.basename extension}" | |||
cmd = "#{Gem.ruby} #{File.basename extension}".dup | |||
cmd << " #{args.join " "}" unless args.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewriting " #{args.join " "}"
as " #{args.join(" ")}"
is clearer to reader there's a string param passed into join
and it's not " #{args.join "
+ "}"
. Maybe use single quotes to be more obvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hmistry These are good ideas. Would you accept a PR from me about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have authority to accept PR's, sorry. Ask @segiddins or other RG core team members. I'm sure they won't mind since it's a low risk fix.
@homu retry |
RakeBuilder: avoid frozen string issue # Description: This PR adds a missing `#dup` ("convert frozen string literal to a mutable String object instance") in the same way that 45966be did. The problem only appears when there're `args` to `.build`. To trigger this behavior, I duplicated a test and added a variable with a non-empty array of an empty string (to have benign test data). **What it looks like without the fix** Without this change, the user's failure will look like this: ``` Gem::Ext::BuildError: ERROR: Failed to build gem native extension. can't modify frozen String, created at /home/travis/.rvm/rubies/jruby-9.1.7.0/lib/ruby/stdlib/rubygems/ext/rake_builder.rb:11 ``` **Reproduce** To reproduce the issue, write a `mkrf_conf.rb` which calls `build`. Here is an example `ext/mkrf_conf.rb` with a failing build: https://github.com/sickill/rainbow/blob/master/ext/mkrf_conf.rb # Tasks: - [x] Describe the problem / feature - [x] Write tests - [x] Write code to solve the problem - [x] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
☀️ Test successful - status |
RakeBuilder: avoid frozen string issue # Description: This PR adds a missing `#dup` ("convert frozen string literal to a mutable String object instance") in the same way that 45966be did. The problem only appears when there're `args` to `.build`. To trigger this behavior, I duplicated a test and added a variable with a non-empty array of an empty string (to have benign test data). **What it looks like without the fix** Without this change, the user's failure will look like this: ``` Gem::Ext::BuildError: ERROR: Failed to build gem native extension. can't modify frozen String, created at /home/travis/.rvm/rubies/jruby-9.1.7.0/lib/ruby/stdlib/rubygems/ext/rake_builder.rb:11 ``` **Reproduce** To reproduce the issue, write a `mkrf_conf.rb` which calls `build`. Here is an example `ext/mkrf_conf.rb` with a failing build: https://github.com/sickill/rainbow/blob/master/ext/mkrf_conf.rb # Tasks: - [x] Describe the problem / feature - [x] Write tests - [x] Write code to solve the problem - [x] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md). (cherry picked from commit 1c95b26)
By enabled Danger, we enable the installation of Rubocop on the CI environment. Rubocop depends on the "rainbow" library which has a build error on certain versions of RubyGems. This has been fixed in newer versions of RubyGems, so let's just update RubyGems prior to trying to install anything. See: ku1ik/rainbow#44 See: rubygems/rubygems#1819
By enabled Danger, we enable the installation of Rubocop on the CI environment. Rubocop depends on the "rainbow" library which has a build error on certain versions of RubyGems. This has been fixed in newer versions of RubyGems, so let's just update RubyGems prior to trying to install anything. See: ku1ik/rainbow#44 See: rubygems/rubygems#1819
By enabled Danger, we enable the installation of Rubocop on the CI environment. Rubocop depends on the "rainbow" library which has a build error on certain versions of RubyGems. This has been fixed in newer versions of RubyGems, so let's just update RubyGems prior to trying to install anything. See: ku1ik/rainbow#44 See: rubygems/rubygems#1819
Related to recent build failures and rubygems/rubygems#1819
Description:
This PR adds a missing
#dup
("convert frozen string literal to a mutable String object instance") in the same way that 45966be did.The problem only appears when there're
args
to.build
. To trigger this behavior, I duplicated a test and added a variable with a non-empty array of an empty string (to have benign test data).What it looks like without the fix
Without this change, the user's failure will look like this:
Reproduce
To reproduce the issue, write a
mkrf_conf.rb
which callsbuild
. Here is an exampleext/mkrf_conf.rb
with a failing build: https://github.com/sickill/rainbow/blob/master/ext/mkrf_conf.rbTasks:
I will abide by the code of conduct.