-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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: suggest nix-shell as well #74993
Conversation
@@ -7,6 +7,7 @@ | |||
use Config; | |||
|
|||
my $program = $ARGV[0]; | |||
my $quoted_command = '"' . shell_quote(@ARGV) . '"'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this guaranteed to be correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likely not - but for corner cases what is 'correct' might be different depending on what shell the user is using, and taking that into account seems excessive.
@@ -38,6 +39,9 @@ | |||
print STDERR <<EOF; | |||
The program ‘$program’ is currently not installed. You can install it by typing: | |||
nix-env -iA nixos.$package | |||
|
|||
Or run it once with: | |||
nix-shell -p $package --run $quoted_command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that should be nix run
then, not nix-shell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nix run
is "experimental" and may even disappear behind a feature flag in the next release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I've seen that change. That's really backwards. nix-shell
is causing lots of trouble for just running applications because of the hooks, now we have a solution, and then it would "disappear" again 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. But we shouldn't recommend it until that problem is solved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is putting nix run
behind a feature flag discussed? I find it very useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -46,6 +50,8 @@ | |||
several packages. You can install it by typing one of the following: | |||
EOF | |||
print STDERR " nix-env -iA nixos.$_->{package}\n" foreach @$res; | |||
print STDERR "\nOr run it once with:\n"; | |||
print STDERR " nix-shell -p $_->{package} --run $quoted_command\n" foreach @$res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
see also #74789 |
Conflicts with #74789 (rewrite of command-not-found to C++) |
Yes, though only somewhat: merging this before #74789 might be fine (it would be an easy-to-resolve conflict there, and make the feature disappear again when #74789 is merged, but I'd say that's fine). Indeed when #74789 is merged first we can close this one (and I could look into building the feature in C++ instead). (#74789 looks fine to me but from the comments it seemed somewhat controversial, so I wasn't sure whether to expect it to be merged any time soon (or at all) ) |
It looks like all improvements of command-not-found are stalled because there is a plan to replace it with nix-index (#39789). I guess I should take that for a spin (as documented at https://github.com/bennofs/nix-index#usage-as-a-command-not-found-replacement) and if it seems nice port this PR to that tool. |
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @