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

command-not-found prints out wrong nix run command #185

Closed
bbjubjub2494 opened this issue Jun 15, 2022 · 7 comments · Fixed by #214
Closed

command-not-found prints out wrong nix run command #185

bbjubjub2494 opened this issue Jun 15, 2022 · 7 comments · Fixed by #214

Comments

@bbjubjub2494
Copy link

On a flakified system, the interactive shell CNF handler responds with something like

The program 'ff2png' is currently not installed. You can install it
by typing:
  nix profile install nixpkgs#farbfeld.out

Or run it once with:
  nix run nixpkgs#farbfeld.out --command ...

It does not appear as though --command is a flag for nix run. nix shell however has such a flag, so the message could be
nix shell nixpkgs#farbfeld.out --command ...

OS: NixOS 22.05
Nix: 2.8.1, 2.9.1

@equirosa
Copy link

Having this same issue 😅 I'll look into fixing it and make a PR.

@equirosa
Copy link

Ok so there's two options:

  • using nix run $toplevel#$attrs -- <args>
  • using nix shell $toplevel#$attrs --command <command>

Personally I prefer the second option, because you'd occasionally have no application defined in the output for "$attrs", which trips up run; but with shell it adds the package to the PATH and then runs whatever comes after --command. Additionally, it allows to use it in conjunction with other programs in a pipe and such.

@emilazy
Copy link

emilazy commented May 23, 2023

I'd recommend the latter with -c instead of --command (just because it takes up less space).

@equirosa
Copy link

equirosa commented Jun 8, 2023

That's fair! I usually like presenting the longer options so new people can understand it more easily at a glance, but they can always run --help at some point later on

@emilazy
Copy link

emilazy commented Jun 8, 2023

Yeah I'm usually a long options defender, but in this case I think teaching people there's a syntax short enough to want to type is valuable. It also reduces confusion with the nix-shell(1) --command option which works slightly differently.

@equirosa
Copy link

That's fair, we should go with -c then! 😁

@figsoda
Copy link
Member

figsoda commented Jun 13, 2023

#214

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.

4 participants