From: "jhawthorn (John Hawthorn) via ruby-core" Date: 2026-06-12T18:07:01+00:00 Subject: [ruby-core:125729] [Ruby Bug#22109] Unexpected or misleading error when subclass of a ractor calls a new method on itself Issue #22109 has been updated by jhawthorn (John Hawthorn). I don't think this has anything to do with the method or the subclass. The message could probably be improved, but the warning exists because instance variables on classes like `Ractor` (or other objects which are shareable without being frozen) are only accessible by the main Ractor. ``` ��� ruby -ve 'Ractor.new{ @foo = 123 }.join' ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [arm64-darwin25] -e:1: warning: Ractor API is experimental and may change in future versions of Ruby. # terminated with exception (report_on_exception is true): -e:1:in 'block in
': can not access instance variables of shareable objects from non-main Ractors (Ractor::IsolationError) -e:1:in 'Ractor#join': thrown by remote Ractor. (Ractor::RemoteError) from -e:1:in '
' -e:1:in 'block in
': can not access instance variables of shareable objects from non-main Ractors (Ractor::IsolationError) ``` ---------------------------------------- Bug #22109: Unexpected or misleading error when subclass of a ractor calls a new method on itself https://bugs.ruby-lang.org/issues/22109#change-117613 * Author: miles-georgi (Miles Georgi) * Status: Open * ruby -v: ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [x86_64-linux] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Hey hey! When I run the following code: ```ruby class SubRactor < Ractor attr_accessor :foo end SubRactor.new { puts foo }.join ``` I get the following error: ``` can not access instance variables of shareable objects from non-main Ractors (Ractor::IsolationError) ``` Unclear if I shouldn't get an error of any sort in this situation, but if this is a legitimate error situation, this error seems inaccurate since Ractors can obviously access instance variables of shareable objects. A tiny script that shows that: ```ruby class C attr_accessor :foo def initialize = self.foo = 100 INSTANCE = new.freeze end raise "not shareable!" unless Ractor.shareable?(C::INSTANCE) Ractor.new { puts C::INSTANCE.foo }.join ``` This prints out 100 as expected instead of giving that error. This happens on both: ruby 4.1.0dev (2026-06-11T14:25:18Z master 8e8682fc23) +PRISM [x86_64-linux] and ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [x86_64-linux] The script is so puny seems I shouldn't upload the file but let me know if I should just always upload a script file when filing these even when they are trivially small. Cheers! -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/