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: suggest nix-shell as well #74993

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions nixos/modules/programs/command-not-found/command-not-found.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Config;

my $program = $ARGV[0];
my $quoted_command = '"' . shell_quote(@ARGV) . '"';
Copy link
Member

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?

Copy link
Member Author

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.


my $dbPath = "@dbPath@";

Expand Down Expand Up @@ -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
Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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 😕

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOF
}
} else {
Expand All @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

}

exit 127;