Project

General

Profile

Actions

Bug #21183

closed

Ractor error with Prism::VERSION

Added by getajobmike (Mike Perham) 21 days ago. Updated 1 day ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:121302]

Description

/Users/mperham/.rubies/ruby-3.4.1/lib/ruby/3.4.0/error_highlight/base.rb:88:in 'ErrorHighlight.prism_find': can not access non-shareable objects in constant Prism::VERSION by non-main Ractor. (Ractor::IsolationError)
#<Thread:0x000000011e89fbb0 run> terminated with exception (report_on_exception is true):
	from /Users/mperham/.rubies/ruby-3.4.1/lib/ruby/3.4.0/error_highlight/base.rb:65:in 'ErrorHighlight.spot'
/Users/mperham/.rubies/ruby-3.4.1/lib/ruby/3.4.0/error_highlight/base.rb:88:in 'ErrorHighlight.prism_find'	from /Users/mperham/.rubies/ruby-3.4.1/lib/ruby/3.4.0/error_highlight/core_ext.rb:6:in 'ErrorHighlight::CoreExt#generate_snippet'
	from /Users/mperham/.rubies/ruby-3.4.1/lib/ruby/3.4.0/error_highlight/core_ext.rb:14:in 'ErrorHighlight::CoreExt#detailed_message'
: 	from /Users/mperham/.rubies/ruby-3.4.1/lib/ruby/3.4.0/did_you_mean/core_ext/name_error.rb:24:in 'DidYouMean::Correctable#detailed_message'

Updated by kddnewton (Kevin Newton) 20 days ago

I believe this has been fixed since the VERSION constant is now frozen. Can you double check that if you are using the latest prism release that this is still a problem for you?

Updated by jeremyevans0 (Jeremy Evans) 4 days ago

  • Status changed from Open to Closed
  • Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED

Fixed in the master branch by f27ed98effff9891d28edc7119d45811bcedd510, marking for backport.

Updated by Earlopain (Earlopain _) 1 day ago

It looks handled on 3.4.2 already:

$ ruby -ve 'require "prism"; puts Prism::VERSION.frozen?'
ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [x86_64-linux]
true

Since this is about error_highlight, it still needs backport for ractor safety: https://github.com/ruby/prism/pull/3503
Currently it fails with the following error (example from https://github.com/ruby/prism/issues/3422):

$  echo 'Ractor.new do unknown rescue $!.detailed_message end; sleep 0.1' > /tmp/a.rb; ruby /tmp/a.rb
/tmp/a.rb:1: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
#<Thread:0x00007f39a3382be0 run> terminated with exception (report_on_exception is true):
/home/user/.rbenv/versions/3.4.2/lib/ruby/3.4.0/error_highlight/base.rb:94:in 'Prism.parse_file': ractor unsafe method called from not main ractor (Ractor::UnsafeError)

And then also https://github.com/ruby/error_highlight/commit/a221a4b0ebc0b90e27c7c7d45903a6e7d79d62a2, no idea if that has been backported yet (I believe it hasn't). In combination, error_highlight works in ractor.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0