Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I think Process.spawn(..., 3 => io) is broken in TruffleRuby. #1892

Closed
ioquatix opened this issue Jan 30, 2020 · 4 comments
Closed

I think Process.spawn(..., 3 => io) is broken in TruffleRuby. #1892

ioquatix opened this issue Jan 30, 2020 · 4 comments
Assignees

Comments

@ioquatix
Copy link
Contributor

e.g. on 19.3.0

koyoko% irb                             
irb(main):001:0> options = {3 => $stderr}
=> {3=>#<IO:fd 2>}
irb(main):002:0> Process.spawn("echo", "cats", **options)
Traceback (most recent call last):
        2: from /home/samuel/.rbenv/versions/truffleruby-19.3.0/bin/irb:31:in `<main>'
        1: from (irb):2
TypeError (wrong argument type Integer (expected Symbol))
irb(main):003:0> Process.spawn("echo", "cats", 3 => $stderr)
cats
=> 576445

The option handling seems a bit messed up.

@eregon
Copy link
Member

eregon commented Jan 30, 2020

That's an interesting behavior.
The source of difference here is that this options are no keyword arguments in the Ruby <= 2.6 sense because it contains non-Symbol keys.

So this works (both MRI and TruffleRuby):

ruby -e 'options={3=>$stderr}; p Process.spawn("echo", "cats", options)' 

In fact, the case with **options also fails on MRI 2.6.5:

$ ruby -ve 'options={3=>$stderr}; p Process.spawn("echo", "cats", **options)'
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
Traceback (most recent call last):
-e:1:in `<main>': hash key 3 is not a Symbol (TypeError)

$ truffleruby -ve 'options={3=>$stderr}; p Process.spawn("echo", "cats", **options)'
truffleruby 19.3.1, like ruby 2.6.5, GraalVM CE Native [x86_64-linux]
-e:1:in `<main>': wrong argument type Integer (expected Symbol) (TypeError)

@eregon
Copy link
Member

eregon commented Jan 30, 2020

On MRI 2.7.0 it works because keyword arguments hashes accept any key. But in 2.6.5 in before, they only accept Symbol keys. So the problem is **options itself raises:

$ ruby -ve 'def m(*args); args; end; options={3=>$stderr};  p m(**options)'
truffleruby 19.3.1, like ruby 2.6.5, GraalVM CE Native [x86_64-linux]
-e:1:in `<main>': wrong argument type Integer (expected Symbol) (TypeError)

@eregon
Copy link
Member

eregon commented Jan 30, 2020

TruffleRuby behaves like MRi 2.6.5 here as far as I can see, so I'll close this issue.
Thank you for reporting it though and digging into what goes wrong.

@eregon eregon closed this as completed Jan 30, 2020
@eregon eregon self-assigned this Jan 30, 2020
@ioquatix
Copy link
Contributor Author

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants