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

Conversation

@raboof
Copy link
Contributor

@raboof raboof commented Dec 4, 2019

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @

@@ -7,6 +7,7 @@
use Config;

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

This comment has been minimized.

@grahamc

grahamc Dec 4, 2019
Member

is this guaranteed to be correct?

This comment has been minimized.

@raboof

raboof Dec 4, 2019
Author Contributor

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

This comment has been minimized.

@FRidh

FRidh Dec 4, 2019
Member

that should be nix run then, not nix-shell

This comment has been minimized.

@grahamc

grahamc Dec 4, 2019
Member

nix run is "experimental" and may even disappear behind a feature flag in the next release.

This comment has been minimized.

@FRidh

FRidh Dec 4, 2019
Member

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 😕

This comment has been minimized.

@grahamc

grahamc Dec 4, 2019
Member

Yes, I agree. But we shouldn't recommend it until that problem is solved.

This comment has been minimized.

@Moredread

Moredread Dec 4, 2019
Contributor

Where is putting nix run behind a feature flag discussed? I find it very useful.

This comment has been minimized.

@@ -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;

This comment has been minimized.

@FRidh

FRidh Dec 4, 2019
Member

same here

@FRidh
Copy link
Member

@FRidh FRidh commented Dec 4, 2019

see also #74789

@prusnak
Copy link
Member

@prusnak prusnak commented Dec 4, 2019

Conflicts with #74789 (rewrite of command-not-found to C++)

@raboof
Copy link
Contributor Author

@raboof raboof commented Dec 5, 2019

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) )

@raboof raboof closed this Jan 8, 2020
@raboof
Copy link
Contributor Author

@raboof raboof commented Apr 19, 2020

Reopening this since #74789 doesn't seem to moving forward for now.

(when #74789 gets merged it's not big deal if this small improvement is lost, and I'll try to PR it there as well :))

@raboof
Copy link
Contributor Author

@raboof raboof commented Jul 7, 2020

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.

@raboof raboof closed this Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.