-
Notifications
You must be signed in to change notification settings - Fork 79
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
ChildProcess::LaunchError when running bundle <anything>
#59
Comments
The error message isn't helpful because Windows is giving us conflicting information. From the docs for CreateProcess:
In your case, |
Yeah, I figured it was something weird like that. In my case though I'm curious about why the command is failing at all. As I said, Open3 has no problem spawning the exact same process, so why is ChildProcess failing? Odd... |
Same issue. Windows 8.1 and Ruby 2.0.0-p247. Any workaround is available? |
What seems to work for me is adding "cmd.exe /c" in front of it. I'm guessing this is because you are actually calling a .bat file and according to the docs:
Now lpApplicationName is set to NULL here: https://github.com/jarib/childprocess/blob/master/lib/childprocess/windows/process_builder.rb#L75 However it seems that just adding it to lpCommandLine does the same trick. |
@rarenerd Indeed - CreateProcess won't execute batch files directly. Both of these seem to solve the problem: ChildProcess.build("ruby", "-S", "bundle")
ChildProcess.build("cmd.exe", "/c", "bundle") |
So is there any way that |
I'm very reluctant to customize behaviour depending on what type of file is being executed. This is also consistent with what we already do on Unix - if you want to have your command interpreted, you need to explicitly run the shell yourself ChildProcess.build("bash", "-c", "echo *")
# vs.
ChildProcess.build("echo", "*") This is deliberately in contrast to I'd be happy to accept a pull requests that documents the Windows workaround though. |
I'm confused. If this is consistent with how Unix does things, then why is the exact same command that works on Unix failing on Windows? Is it just because Windows ignores the hash bang at the start of the file whereas Unix uses that information? If that's the case, couldn't |
I didn't claim it is consistent with "how Unix does things", but that ChildProcess is consistent in the decision not to execute commands through a command-line interpreter on either platform. Even if you consider that moot, I can't imagine what a satisfactory heuristic to detect when to execute in If you know you always want def create_process(*cmd)
cmd.unshift("cmd.exe", "/c") if ChildProcess.windows?
ChildProcess.build(*cmd)
end |
Hmm, yeah I think I see what you're saying. Obviously you don't want to interpret any shell commands passed to Is there a reason though that we can't just use the hash-bang in the first line of a file to determine whether or not to invoke an interpreter? That's what Unix does, right? Although, usually the paths to the interpreters used in hash-bang lines are very Unix-specific, so maybe that wouldn't work... |
Hold on a second! How does |
Open3 uses |
For some reason, I'm getting the following error whenever I try to run
bundle
with ChildProcess:That error message isn't very helpful. So Windows is saying that everything's fine but you say Windows is lying because... why?
Open3 has no problem running the bundle command:
The text was updated successfully, but these errors were encountered: