Skip to content
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

Fix longstanding gem install failure on JRuby #5228

Merged
merged 1 commit into from Jan 4, 2022

Conversation

deivid-rodriguez
Copy link
Member

What was the end-user or developer problem that led to this PR?

On JRuby, sometimes we get the following error in CI when running a realworld test that checks that gem install rails succeeds:

ERROR:  While executing gem ... (NoMethodError)
    undefined method `ignored=' for nil:NilClass
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/stub_specification.rb:193:in `to_spec'
	org/jruby/RubyArray.java:2642:in `map'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/specification.rb:758:in `_all'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/specification.rb:956:in `each'
	org/jruby/RubyEnumerable.java:1710:in `any?'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/resolver/activation_request.rb:111:in `installed?'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/request_set.rb:173:in `block in install'

What is your fix for the problem, implemented in this PR?

I'm not sure how this error is happening, but I think there's no need to copy the @ignored instance variable when materializing stub specifications. This instance variable is used to not print a warning about missing extensions more than once for each gem upon gem activation, but as far as I can see, it's only used by methods that work on specification stubs. Once specifications are materialized, I think it can be safely ignored.

Make sure the following tasks are checked

On JRuby, sometimes we get the following error in CI when running a
realworld test that checks that `gem install rails` succeeds:

```
ERROR:  While executing gem ... (NoMethodError)
    undefined method `ignored=' for nil:NilClass
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/stub_specification.rb:193:in `to_spec'
	org/jruby/RubyArray.java:2642:in `map'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/specification.rb:758:in `_all'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/specification.rb:956:in `each'
	org/jruby/RubyEnumerable.java:1710:in `any?'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/resolver/activation_request.rb:111:in `installed?'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/request_set.rb:173:in `block in install'
```

I'm not sure how this error is happening, but I think there's no need to
copy the `@ignored` instance variable when materializing stub
specifications. This instance variable is used to not print a warning
about missing extensions more than once for each gem upon gem
activation, but as far as I can see, it's only used by methods that work
on specification stubs. Once specifications are materialized, I think
it can be safely ignored.
@deivid-rodriguez
Copy link
Member Author

Some JRuby users are also running into this, so I'm going to tentatively merge this.

@deivid-rodriguez deivid-rodriguez merged commit 257dbdb into master Jan 4, 2022
@deivid-rodriguez deivid-rodriguez deleted the fix_race_condition_on_jruby branch January 4, 2022 22:25
deivid-rodriguez added a commit that referenced this pull request Jan 12, 2022
Fix longstanding `gem install` failure on JRuby

(cherry picked from commit 257dbdb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant