Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
`system` method is different behavior from JRuby 1.7.x and CRuby 2.3.x #3653
I'am preparing to release Rake 11. but Rake master has some blocker related JRuby 184.108.40.206.
I investigated 3 and 4 in above log. I found strange difference at JRuby 220.127.116.11. Please see re-produce code: https://github.com/hsbt/rake-issue-chdir
JRuby 18.104.22.168 expand ENV variables to environmental variable in
Is this intentional behavior?
This was referenced
Feb 9, 2016
Ok, the problem here is that the new logic for process spawning does not support chdir in the same way as MRI.
In MRI, if you specify chdir when calling spawn or system or whatever, it will actually do a native chdir before launching the child process. It does this either after forking or temporarily around the call to spawn(2) (setting it back after launching the process).
MRI also actually does a real native chdir when doing
We have never been comfortable changing the directory the JVM is running in, because we worry that will at least confuse the JVM and at worst interfere with other threads or applications running in the same process. However, we have never tested real chdir to see if anything bad happens.
A short term fix for this in JRuby would be to fall back on the old JVM process logic when we need to chdir, since that logic uses fork+exec similar to MRI. This might be ok for system, since all it does is capture all child process output. However, it would be too great a change for e.g.
It's worth pointing out that MRI will behave the same as us even without chdir if the command given looks like a command line. For example, if I change
MRI will also expand the env var. So it's a bit fragile to build commands that have loose env var references and expect them not to expand.
I agreed. Rake has expantion and no expantion tests at https://github.com/ruby/rake/blob/master/test/test_rake_file_utils.rb#L140 . I didn't know why CRuby shows this behavior.
I will discuss this to CRuby core team.
added a commit
Feb 15, 2016
(Not sure right place to post or make issue, so thought I'd start here with a comment.)
Excerpt for convenience: