From: "headius (Charles Nutter) via ruby-core" Date: 2023-05-14T05:12:38+00:00 Subject: [ruby-core:113475] [Ruby master Bug#18933] Dir.tmpdir implemented in non-Ractor-safe manner Issue #18933 has been updated by headius (Charles Nutter). Why not just put this in a private constant? I believe that would be Ractor-safe and it would make more sense than a lazy class variable or class instance variable (that's not actually lazy). ---------------------------------------- Bug #18933: Dir.tmpdir implemented in non-Ractor-safe manner https://bugs.ruby-lang.org/issues/18933#change-103057 * Author: kreynolds (Kelley Reynolds) * Status: Open * Priority: Normal * ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- # Background Inside a Ractor, it is expected that generating a temporary directory using `Dir.tmpdir` will work. The current implementation uses a number of things which are not considered Rector-safe and will require refactoring. # How to reproduce ```ruby Ractor.new { Dir.tmpdir } ``` # Expectation and result The result is expected to be something along the lines of `"/var/folders/xm/y4c00x0s26sgf_zlnqjh_7800000gn/T"` but instead a `Ractor::IsolationError` exception is raised: ```ruby 3.1.2/lib/ruby/3.1.0/tmpdir.rb:23:in `tmpdir': can not access class variables from non-main Ractors (Ractor::IsolationError) ``` # Suggested solutions * Make cached class variable a shareable constant * Modify how random values are generated to be Rector-safe ---Files-------------------------------- tmpdir.diff (1.77 KB) -- 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/postorius/lists/ruby-core.ml.ruby-lang.org/