-
Notifications
You must be signed in to change notification settings - Fork 174
Closed
Description
Hello,
I found that Prism::VERSION can't be referred by non-main Ractor.
$ ruby -rprism -e 'Ractor.new do Prism::VERSION end.take'
-e:1: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
#<Thread:0x00007f1b5a5704c8 run> terminated with exception (report_on_exception is true):
-e:1:in 'block in <main>': can not access non-shareable objects in constant Prism::VERSION by non-main Ractor. (Ractor::IsolationError)
<internal:ractor>:711:in 'Ractor#take': thrown by remote Ractor. (Ractor::RemoteError)
from -e:1:in '<main>'
-e:1:in 'block in <main>': can not access non-shareable objects in constant Prism::VERSION by non-main Ractor. (Ractor::IsolationError)
This prevents error_highlight from working properly on non-main Ractor.
$ 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:0x00007f9d37061f18 run> terminated with exception (report_on_exception is true):
/home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+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)
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/base.rb:65:in 'ErrorHighlight.spot'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/core_ext.rb:6:in 'ErrorHighlight::CoreExt#generate_snippet'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/core_ext.rb:14:in 'ErrorHighlight::CoreExt#detailed_message'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/did_you_mean/core_ext/name_error.rb:24:in 'DidYouMean::Correctable#detailed_message'
from /tmp/a.rb:1:in 'block in <main>'
<internal:ast>:96:in 'RubyVM::AbstractSyntaxTree.of': cannot get AST for ISEQ compiled by prism (RuntimeError)
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/base.rb:59:in 'ErrorHighlight.spot'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/core_ext.rb:6:in 'ErrorHighlight::CoreExt#generate_snippet'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/core_ext.rb:14:in 'ErrorHighlight::CoreExt#detailed_message'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/did_you_mean/core_ext/name_error.rb:24:in 'DidYouMean::Correctable#detailed_message'
from /tmp/a.rb:1:in 'block in <main>'
/home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+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)
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/base.rb:65:in 'ErrorHighlight.spot'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/core_ext.rb:6:in 'ErrorHighlight::CoreExt#generate_snippet'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/core_ext.rb:14:in 'ErrorHighlight::CoreExt#detailed_message'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/did_you_mean/core_ext/name_error.rb:11:in 'DidYouMean::Correctable#detailed_message'
from /tmp/a.rb:1:in 'block in <main>'
<internal:ast>:96:in 'RubyVM::AbstractSyntaxTree.of': cannot get AST for ISEQ compiled by prism (RuntimeError)
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/base.rb:59:in 'ErrorHighlight.spot'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/core_ext.rb:6:in 'ErrorHighlight::CoreExt#generate_snippet'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/error_highlight/core_ext.rb:14:in 'ErrorHighlight::CoreExt#detailed_message'
from /home/wanabe/.rbenv/versions/master/lib/ruby/3.5.0+0/did_you_mean/core_ext/name_error.rb:11:in 'DidYouMean::Correctable#detailed_message'
from /tmp/a.rb:1:in 'block in <main>'
It is not impossible to solve this problem by calling Ractor.make_shareable or String#freeze by user program.
However, if the library can solve the problem, it would be more appreciated. (Perhaps similar to ruby/io-console#82)
Thank you to read.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels