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

Usefulness of Unix.open_process_args* functions is limited by them not respecting PATH environment variable #10083

Closed
frou opened this issue Dec 13, 2020 · 2 comments · Fixed by #10084

Comments

@frou
Copy link

frou commented Dec 13, 2020

As an alternative to the other Unix.open_process* functions (that take a single string and rely on Filename.quote_command), these Unix.open_process_args* functions introduced in 4.08 are nice. But crucially they don't currently respect the PATH environment variable, limiting their usefulness.

e.g. I'd expect the following to work, since /usr/bin is mentioned in my PATH and the executable /usr/bin/uname exists.

let ic, oc = Unix.open_process_args "uname" [| "uname"; "-a" |]
let status = Unix.close_process (ic, oc)

But status is Unix.WEXITED 127 because the executable couldn't be found.

I think this is beacause the implementation is using the execv syscall rather than execvp.

@nojb
Copy link
Contributor

nojb commented Dec 13, 2020

Related/duplicate of #10057. I agree that we should probably fix this.

@frou
Copy link
Author

frou commented Dec 13, 2020

Wow you're fast! You managed to cross-reference them before I did :)

xavierleroy pushed a commit that referenced this issue Dec 21, 2020
The `Unix.open_process_args*` used to treat their first arguments as a file name for the executable to be run, like `execv` does.

This commit ensures that the first argument is searched in the executable path, like `execvp` does.  This is a more useful behavior.

 Closes: #10083
dbuenzli pushed a commit to dbuenzli/ocaml that referenced this issue Mar 25, 2021
The `Unix.open_process_args*` used to treat their first arguments as a file name for the executable to be run, like `execv` does.

This commit ensures that the first argument is searched in the executable path, like `execvp` does.  This is a more useful behavior.

 Closes: ocaml#10083
akabe added a commit to akabe/ocaml-jupyter that referenced this issue Mar 31, 2022
akabe added a commit to akabe/ocaml-jupyter that referenced this issue Apr 3, 2022
🐛 don't use Unix.open_process_* on 4.12

ocaml/ocaml#10083
akabe added a commit to akabe/ocaml-jupyter that referenced this issue Apr 9, 2022
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

Successfully merging a pull request may close this issue.

2 participants