-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Issue with prefixing "system" commands with ENV variables in Dir.chdir #5145
Comments
(FWIW, I noted that MRI has problems with these commands also, but "different problems". It fails to populate |
This is a known issue. The main reason it fails is that we maintain a notion of "cwd" that is not tied to the system level current directory. We do this to allow running multiple JRuby instances in the same process with their own cwd's. However this means that we must always simulate cwd when opening files, running subprocesses and so on. For processes, this usually means that we run the command as a In dealing with some cwd-related failures today, I started to wonder if we should just go ahead and try a real system-level chdir call. We'd still need to have support for multi-tenant cwd, but since most folks using chdir will be running a single JRuby instance from a command line, giving them a real chdir might be nice. @enebo What sayeth you? |
@headius will that only effect the current thread? We could detect multiple runtimes in one vm as well so not exactly sure if we then toggle back to emulating or not? I do like the idea of it though. What we are doing is never quite the right fit. |
@enebo No, the native chdir changes process-global state. All threads would see the new cwd. Unfortunately the only other option is what we do now.* (*There is another option but it would require us to have native code that forks, chdirs, and then execs. MRI does this if it can fork, or chdirs before/after a spawn call if fork is not available.) |
There have been other fixes to better support We'll call this one invalid/duplicate. If there's a specific case that doesn't work, ask us about it or open a new issue and we can deal with these on a case-by-case basis. |
Okay, this is a weird one. https://github.com/perlun/jruby-system-chdir-bug is a repro repo that has everything in place to illustrate the issue.
Basically, a
Rakefile
that looks like this:...behaves differently on MRI and JRuby.
On MRI:
On JRuby:
jruby-head
unfortunately doesn't work either, and doesn't even give me the error details:Observations
Dir.chdir
call & block makes it work as expected, so it seems to be specifically this circumstance (being in a different folder or something else thatchdir
changes in the context.)FOO=bar
prefix also makes it work, but is a bit bad because I need the prefix in certain scenarios.The text was updated successfully, but these errors were encountered: