You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In CRuby, when Process.spawn is given an invalid chdir: option (pointing to a nonexistent directory), it raises an Errno::ENOENT error. However, in TruffleRuby, Process.spawn does not raise an error. Instead, it returns a Process::Status object with exitstatus == 1.
This behavior creates ambiguity—it’s unclear whether the subprocess failed to start or if it started and exited with a failure code.
Expected Behavior (CRuby 3.4.1)
When Process.spawn is called with a nonexistent chdir: directory, it should raise an error:
$ ruby --version
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [arm64-darwin24]
$ irb
irb(main):001> Process.wait2(Process.spawn('pwd', chdir: 'does_not_exist'))
(irb):1:in 'Process.spawn': No such file or directory - does_not_exist (Errno::ENOENT)
Actual Behavior (TruffleRuby 24.1.2)
Instead of raising an error, TruffleRuby prints an error message but returns a Process::Status object:
$ ruby --version
truffleruby 24.1.2, like ruby 3.2.4, Oracle GraalVM Native [arm64-darwin20]
$ irb
irb(main):001:0> Process.wait2(Process.spawn('pwd', chdir: 'does_not_exist'))
chdir: No such file or directory
working_directory=does_not_exist
=> [69902, #<Process::Status: pid 69902 exit 1>]
Why This is a Problem
Inconsistent with CRuby Behavior: TruffleRuby’s behavior deviates from the standard Ruby implementation.
Ambiguous Error Handling: When Process::Status has exitstatus == 1, there’s no clear way to distinguish between:
A subprocess that failed to start (e.g., due to an invalid chdir:).
A subprocess that started but exited with failure.
Cross-Ruby Compatibility: I maintain a Ruby gem that calls Process.spawn, and this difference in behavior makes it difficult to ensure consistent error handling across Ruby implementations.
Questions for the TruffleRuby Team
Is this behavior intentional?
If so, how should developers differentiate between a process that couldn’t start vs. one that started and failed?
Would it be possible to align TruffleRuby with CRuby by raising Errno::ENOENT in this case?
Thanks for your time and consideration!
The text was updated successfully, but these errors were encountered:
Upon reviewing my initial report, I believe I overlooked the possibility of additional errors that could occur and trigger a CRuby exception.
Generally, if there is an issue that prevents Ruby from executing the subprocess, it should raise an error. Returning a Process::Status should be reserved for reporting on the outcomes of the subprocess’s execution.
In CRuby, when Process.spawn is given an invalid chdir: option (pointing to a nonexistent directory), it raises an Errno::ENOENT error. However, in TruffleRuby, Process.spawn does not raise an error. Instead, it returns a Process::Status object with exitstatus == 1.
This behavior creates ambiguity—it’s unclear whether the subprocess failed to start or if it started and exited with a failure code.
Expected Behavior (CRuby 3.4.1)
When Process.spawn is called with a nonexistent chdir: directory, it should raise an error:
Actual Behavior (TruffleRuby 24.1.2)
Instead of raising an error, TruffleRuby prints an error message but returns a Process::Status object:
Why This is a Problem
Questions for the TruffleRuby Team
Thanks for your time and consideration!
The text was updated successfully, but these errors were encountered: