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

bug: Fish shell error /etc/profiles/per-user/user/bin/command-not-found #3858

Open
2 tasks done
mudrii opened this issue Apr 9, 2023 · 5 comments
Open
2 tasks done
Assignees
Labels
bug status: stale triage Issues or feature request that have not been triaged yet

Comments

@mudrii
Copy link

mudrii commented Apr 9, 2023

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

Getting an error post install if using fish as primary on nix-darwin
Using fish as shell and if typing command that doesn't exist getting errors below

/etc/profiles/per-user/user/bin/command-not-found: line 3: use: command not found
/etc/profiles/per-user/user/bin/command-not-found: line 4: use: command not found
/etc/profiles/per-user/user/bin/command-not-found: line 5: use: command not found
/etc/profiles/per-user/user/bin/command-not-found: line 6: use: command not found
/etc/profiles/per-user/user/bin/command-not-found: line 7: use: command not found
/etc/profiles/per-user/user/bin/command-not-found: line 9: my: command not found
/etc/profiles/per-user/user/bin/command-not-found: line 11: my: command not found
/etc/profiles/per-user/user/bin/command-not-found: line 13: syntax error near unexpected token `('
/etc/profiles/per-user/user/bin/command-not-found: line 13: `my $dbh = DBI->connect("dbi:SQLite:dbname=$dbPath", "", "")'
la /etc/profiles/per-user/user/bin/command-not-found
Permissions Size User Group Date Modified Name
lrwxr-xr-x    83 root wheel  1 Jan  1970   /etc/profiles/per-user/user/bin/command-not-found -> /nix/store/7b864y0pncqy8wqplnwnirpfcygy67sn-home-manager-path/bin/command-not-found
cat /nix/store/7b864y0pncqy8wqplnwnirpfcygy67sn-home-manager-path/bin/command-not-found                                                              2818ms
#! /nix/store/2ivbs4wdlv799hmdhlwq4vpbdhr7xxn7-perl-5.36.0-env/bin/perl -w

use strict;
use DBI;
use DBD::SQLite;
use String::ShellQuote;
use Config;

my $program = $ARGV[0];

my $dbPath = "/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite";

my $dbh = DBI->connect("dbi:SQLite:dbname=$dbPath", "", "")
    or die "cannot open database `$dbPath'";
$dbh->{RaiseError} = 0;
$dbh->{PrintError} = 0;

my $system = $ENV{"NIX_SYSTEM"} // $Config{myarchname};

my $res = $dbh->selectall_arrayref(
    "select package from Programs where system = ? and name = ?",
    { Slice => {} }, $system, $program);

if (!defined $res || scalar @$res == 0) {
    print STDERR "$program: command not found\n";
} elsif (scalar @$res == 1) {
    my $package = @$res[0]->{package};
    if ($ENV{"NIX_AUTO_RUN"} // "") {
        exec("nix-shell", "-p", $package, "--run", shell_quote("exec", @ARGV));
    } else {
        print STDERR <<EOF;
The program '$program' is not in your PATH. You can make it available in an
ephemeral shell by typing:
  nix-shell -p $package
EOF
    }
} else {
    print STDERR <<EOF;
The program '$program' is not in your PATH. It is provided by several packages.
You can make it available in an ephemeral shell by typing one of the following:
EOF
    print STDERR "  nix-shell -p $_->{package}\n" foreach @$res;
}

exit 127;

Maintainer CC

No response

System information

- system: `"aarch64-darwin"`
 - host os: `Darwin 22.4.0, macOS 13.3.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.13.3`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
@mudrii mudrii added bug triage Issues or feature request that have not been triaged yet labels Apr 9, 2023
@mudrii mudrii changed the title bug: Fish shell error /etc/profiles/per-user/mudrii/bin/command-not-found bug: Fish shell error /etc/profiles/per-user/user/bin/command-not-found Apr 9, 2023
@ncfavier
Copy link
Member

ncfavier commented Apr 9, 2023

command-not-found does not have fish integration. It looks like your fish_command_not_found handler is sourcing the command-not-found executable, so you need to figure out what's doing that and what it expects command-not-found to be.

@montchr
Copy link

montchr commented Jun 26, 2023

I've also just run into this issue on aarch64-darwin. fish is not my default shell, but I do have nix-darwin's programs.fish.enable = true in addition to home-manager's equivalent option. I ran into this in a session initiated by calling fish directly from a zsh session, if it matters.

@stale
Copy link

stale bot commented Sep 28, 2023

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

@stale stale bot added the status: stale label Sep 28, 2023
@trueNAHO
Copy link
Contributor

trueNAHO commented Oct 10, 2023

For reference, I ingeniously overload my fish_command_not_found function with nix run as follows:

https://github.com/trueNAHO/dotfiles/blob/6df0a91149e10ac2c64bb7733a14ee4c4699a5c7/homeManager/programs/fish/default.nix#L28-L31

@stale stale bot removed the status: stale label Dec 23, 2023
Copy link

stale bot commented Mar 31, 2024

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

@stale stale bot added the status: stale label Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status: stale triage Issues or feature request that have not been triaged yet
Projects
None yet
Development

No branches or pull requests

7 participants