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

sys::exec_wait("command", "-v", "foo") seems to not work #40

Closed
philipp-baumann opened this issue Aug 11, 2023 · 2 comments
Closed

sys::exec_wait("command", "-v", "foo") seems to not work #40

philipp-baumann opened this issue Aug 11, 2023 · 2 comments

Comments

@philipp-baumann
Copy link

Don't know if this is expected behavior, edge case, or my own wrong usage.

> out <- system2("command", "-v", "nix-build")
> sys::exec_wait("command", "-v", "nix-build")
Error: Failed to execute 'command' (No such file or directory)
> out
[1] 0
@jeroen
Copy link
Owner

jeroen commented Aug 11, 2023

sys runs programs, but maybe on your system, command is not an executable, but a shell-built-in:

See: https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html

In this case you need to invoke your shell program to use that command, which is what system2 does:

sys::exec_wait("sh", c("-c", "command -v nix-build"))

If you just want to test if a program exists on the path, you can also use:

Sys.which("nix-build")

@philipp-baumann
Copy link
Author

thank you so much for explaining!

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