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

Nix sh command dependency #34

Open
josh opened this issue Jan 26, 2025 · 2 comments
Open

Nix sh command dependency #34

josh opened this issue Jan 26, 2025 · 2 comments
Assignees

Comments

@josh
Copy link

josh commented Jan 26, 2025

I was experimenting with some of the nice Pimalaya CLI tools via Nix and noticed a few cases where running in an isolated environment (without PATH set) caused subcommands to fail.

let (shell, arg) = if windows { ("cmd", "/C") } else { ("sh", "-c") };

Here it's assumed sh is provided in the environment PATH.

I think this assumption could be reasonable, and the usual fix at the nix package level is to create a wrapper ensuring pkgs.bash is set on the PATH.

An alternative approach might be to make this dependency explicitly configurable at compile time, avoiding the need for additional wrappers. I'm not very familiar with Rust, but is there a compile-time flag convention for specifying runtime tool locations, such that the bash path could be baked into the binary?

Just curious what you think about this? Thanks!

@soywod
Copy link
Member

soywod commented Jan 27, 2025

Very good question. To be honest I am not that fan of this wrapper anymore. It already shown its limit many times. It's been a while I think about just getting rid of it for the following reasons:

  1. No more issue with sh not found
  2. No more OS condition
  3. People can still decide to wrap their own command, manually

Let's keep this issue open for the purpose of removing it. Thank you for finally initiating this refactor!

@soywod soywod added the bug Something isn't working label Jan 27, 2025
@soywod soywod added this to Pimalaya Jan 27, 2025
@soywod soywod removed the bug Something isn't working label Jan 27, 2025
@soywod soywod moved this to Todo in Pimalaya Jan 27, 2025
@soywod soywod self-assigned this Jan 27, 2025
@josh
Copy link
Author

josh commented Jan 27, 2025

Oh, right, I didn't even consider dropping the sh subshell all together. I assume that's what you mean. Much simpler. I think as along as there's some basic parsing for additional arguments and handling quoting nuances, that'd be good enough for most people. And if you really want to have pipes and stuff in that expression, you can call sh -c yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants