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

Prevent abort call within gem from breaking tapioca gem command #1826

Merged
merged 1 commit into from
Mar 18, 2024

Conversation

andyw8
Copy link
Contributor

@andyw8 andyw8 commented Mar 15, 2024

Motivation

I was encountering a Parallel::DeadWorker exception when running tapioca gem on a new project:

bundler: failed to load command: tapioca (/Users/andyw8/.gem/ruby/3.1.1/bin/tapioca)
/Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:83:in `rescue in work': Parallel::DeadWorker (Parallel::DeadWorker)
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:80:in `work'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:522:in `block (4 levels) in work_in_processes'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:637:in `with_instrumentation'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:521:in `block (3 levels) in work_in_processes'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:509:in `loop'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:509:in `block (2 levels) in work_in_processes'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:219:in `block (4 levels) in in_threads'
<internal:marshal>:34:in `load': end of file reached (EOFError)
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:81:in `work'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:522:in `block (4 levels) in work_in_processes'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:637:in `with_instrumentation'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:521:in `block (3 levels) in work_in_processes'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:509:in `loop'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:509:in `block (2 levels) in work_in_processes'
	from /Users/andyw8/.gem/ruby/3.1.1/gems/parallel-1.24.0/lib/parallel.rb:219:in `block (4 levels) in in_threads'

With @Morriar's help we determined that the generation for the rdoc gem was failing:

bundle exec tapioca gem rdoc

(rdoc is a dependency of both irb and debug so this may impact a lot of people).

It outputs webrick is not found. You may need to `gem install webrick` to install webrick. and no RBI file is generated.

This is due to the abort here: https://github.com/ruby/rdoc/blob/d0074a23cc835b09d72ddd2f98d10eee4d23e1ab/lib/rdoc/servlet.rb#L10

(the Servlet class is autoloaded here).

Implementation

We re-used the with_disabled_exits mechanism Tapioca already had. But we're unsure if where we added it is at the right level.

Tests

None yet... may be tricky.

@andyw8 andyw8 added the bugfix label Mar 15, 2024
@andyw8 andyw8 marked this pull request as ready for review March 15, 2024 19:49
@andyw8 andyw8 requested a review from a team as a code owner March 15, 2024 19:49
@andyw8 andyw8 requested review from st0012 and vinistock March 15, 2024 19:49
Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good to me, but I wonder if we should wrap the entire command in that. Is there ever a scenario where we want the code to abort or exit without that being controlled by Tapioca?

@andyw8
Copy link
Contributor Author

andyw8 commented Mar 15, 2024

I suppose there is a very small risk that someone could have a gem which does something dangerous if the real abort doesn't get called.

Copy link
Collaborator

@Morriar Morriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failures are unrelated. I'm working on it.

Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(rdoc is a dependency of both rbi and debug so this may impact a lot of people).

By rbi, maybe you meant irb? 😉

@andyw8 andyw8 merged commit 3e57203 into main Mar 18, 2024
25 of 35 checks passed
@andyw8 andyw8 deleted the andyw8/prevent-abort-breakage branch March 18, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants