Project

General

Profile

Actions

Bug #17676

closed

Accessing ENV from Ractor raises IsolationError

Added by delner (David Elner) about 3 years ago. Updated 7 months ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
[ruby-core:102774]
Tags:

Description

Background

Accessing ENV variables from a Ractor will raise Ractor::IsolationError, as the Hash is non-shareable.

How to reproduce

ractor = Ractor.new do
 ENV['PATH']
end
 
ractor.take

Expectation and result

Ractor raises Ractor::IsolationError for ENV

Expect to be able to access ENV variables from Ractors without raising an error.

`block in <main>': can not access non-shareable objects in constant Object::ENV by non-main Ractor. (Ractor::IsolationError)

Additional Notes

Attempting to create a shareable copy of ENV currently fails:

Ractor.make_shareable(ENV, copy: true)
# TypeError: cannot freeze ENV
# from <internal:ractor>:812:in `freeze'

Suggested solutions

  1. If ENV is a mutable hash, make a Ractor-compatible copy of ENV isolated to that Ractor.
Actions #1

Updated by delner (David Elner) about 3 years ago

  • Description updated (diff)

Updated by hsbt (Hiroshi SHIBATA) about 3 years ago

  • Tags set to ractor
  • Status changed from Open to Assigned
  • Assignee set to ko1 (Koichi Sasada)

Updated by ko1 (Koichi Sasada) about 3 years ago

I agree ENV should be shareable.
It is in my task list, but not high priority.

Updated by jeremyevans0 (Jeremy Evans) 7 months ago

  • Status changed from Assigned to Closed

Updated by ivoanjo (Ivo Anjo) 7 months ago

Thank you Jeremy! :)

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0