NixOS/nixpkgs

fish error when ``programs.fish.vendor.config.enable = true``

Closed this issue ยท 18 comments

Describe the bug

When programs.fish.vendor.config.enable = true, I get the following error at every fish prompt:

fish: Unknown command: fzf_key_bindings
/run/current-system/sw/share/fish/vendor_conf.d/load-fzf-key-bindings.fish (line 1):
fzf_key_bindings
^~~~~~~~~~~~~~~^
from sourcing file /run/current-system/sw/share/fish/vendor_conf.d/load-fzf-key-bindings.fish
        called on line 248 of file /nix/store/mnmy8xws1zxblajvnal6v11i32ji4qp6-fish-3.6.1/share/fish/config.fish

When I set it to false, the error goes away.

Steps To Reproduce

Steps to reproduce the behavior:

  1. set programs.fish.vendor.config.enable = true in your config. (this is the default.
  2. open the fish shell in a terminal
  3. see the error

Expected behavior

No error.

Notify maintainers

@cole-h @Winter @srapenne

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.5.7, NixOS, 23.11 (Tapir), 23.11pre536534.ca012a02bf83`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.17.0`
 - channels(root): `"nixos, nixos-hardware"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

I encountered the same problem after updating packages with:

cd nix-config
nix flake update
darwin-rebuild switch --flake .

But starting new shells don't have the problem, so I restarted all existing shells.

nix-info:

  • system: "aarch64-darwin"
  • host os: Darwin 21.6.0, macOS 12.7
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.17.1
  • channels(root): "nixpkgs"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixpkgs

@goofansu Thanks for the reply.
I tried to reproduce your findings, but ran into #262266, so I can't test.

I think this was addressed here yesterday: #261778

@magnetophon Sorry I was wrong, the error still happens, but only in git projects, so I wasn't noticed the problem. I installed fzf 0.40.0 in the 23.05 branch temporarily.

I have upgraded from 23.05 to unstable and now I have the same problem as magnetophon.

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.5.7, NixOS, 23.11 (Tapir), 23.11pre536534.ca012a02bf83`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.17.0`
 - channels(root): `"nixos"`
 - channels(juan): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Parts of configuration.nix where I refer to fish and its plugins:

....
  users = {
    users.juan.isNormalUser = true;
    users.juan.description = "Juan";
    users.juan.extraGroups = [ "networkmanager" "wheel" ];
    users.juan.packages = with pkgs; [
...
    ];

    defaultUserShell = pkgs.fish;
  };
...
  environment = {

    systemPackages = with pkgs; [
      vscodium
      fishPlugins.done
      fishPlugins.tide
      fishPlugins.fzf-fish
      fzf
      fishPlugins.grc
      grc
      fishPlugins.colored-man-pages
      nil
      nixpkgs-fmt
      git
      nodejs
      plocate
      fd
      wget
    ];

    shells = with pkgs; [ fish ];
  };

  programs.fish = {
    enable = true;
    interactiveShellInit = ''
      set fish_greeting # Disable greeting
    '';
  };
....

@simonbcn Just wait for #261778 backported to unstable, but I didn't see the backport PR.

Using nixpkgs-unstable (which has landed the PR), the issue has been fixed specifically for fzf, but not for tide.
While the custom prompt is working, there's the error:

fish: Unknown command: _tide_item_virtual_env
/run/current-system/sw/share/fish/vendor_functions.d/_tide_1_line_prompt.fish (line 11): 
        _tide_item_$item
        ^~~~~~~~~~~~~~~^
in function '_tide_1_line_prompt'
in command substitution
fish: Unknown command: _tide_item_chruby
/run/current-system/sw/share/fish/vendor_functions.d/_tide_1_line_prompt.fish (line 11): 
        _tide_item_$item
        ^~~~~~~~~~~~~~~^
in function '_tide_1_line_prompt'

EDIT: Fixed by deleting ~/.config/fish/fish_variables.

r-vdp commented

@simonbcn Just wait for #261778 backported to unstable, but I didn't see the backport PR.

A backport should not be needed, since 23.05 is still on fzf 0.40 which should not be affected. Only unstable was affected.

r-vdp commented

You can always apply the patch from the PR to fzf in your local config while we wait for hydra: (@pbek)

pkgs.fzf.overrideAttrs(_: prev: {
  patches = (prev.patches or [ ]) ++ [
    (pkgs.fetchpatch {
      name = "fzf-fix-fish-key-bindings.patch";
      url = "https://github.com/NixOS/nixpkgs/pull/261778.diff";
      hash = "sha256-DSdB9VxNuCS1j0hWkzUVM1jXLWAIcVWnMriPgs2YDJs=";
    })
  ];
})
pbek commented

Thank you, @r-vdp! Have to play with that more, the config caused some errors for me...

r-vdp commented

@pbek oh sorry, my fault, the PR patch would need to be applied to nixpkgs as a whole, not the fzf source, you can do it like this though:

pkgs.fzf.overrideAttrs (final: prev: {
  postInstall = (prev.postInstall or "") + ''
    cat << EOF > $out/share/fish/vendor_conf.d/load-fzf-key-bindings.fish
      status is-interactive; or exit 0
      fzf_key_bindings
    EOF
  '';
});
pbek commented

Didn't work either ๐Ÿ˜…

r-vdp commented

Didn't work either ๐Ÿ˜…

Hmm, it should, we can discuss in the support channel on matrix or such if you want, that's probably better than here

@pbek oh sorry, my fault, the PR patch would need to be applied to nixpkgs as a whole, not the fzf source, you can do it like this though:

pkgs.fzf.overrideAttrs (final: prev: {
  postInstall = (prev.postInstall or "") + ''
    cat << EOF > $out/share/fish/vendor_conf.d/load-fzf-key-bindings.fish
      status is-interactive; or exit 0
      fzf_key_bindings
    EOF
  '';
});

@r-vdp Thanks, it works.

@pbek Do you use home-manager? If so, it works like:

{ pkgs, ... }:

{
  programs.fzf = {
    enable = true;
    package = pkgs.fzf.overrideAttrs (final: prev: {
      postInstall = (prev.postInstall or "") + ''
        cat << EOF > $out/share/fish/vendor_conf.d/load-fzf-key-bindings.fish
          status is-interactive; or exit 0
          fzf_key_bindings
        EOF
      '';
    });
  };
}
pbek commented

@goofansu, yes, I do use home-manager. ๐Ÿ˜ Thank you, that worked!
@r-vdp, sorry for messing up the GitHub issue. ๐Ÿ˜…

In reply to my previous message, I fixed it by deleting ~/.config/fish/fish_variables.

pbek commented

It's fixed for me now in nixpkgs unstable! ๐Ÿ‘๐Ÿป

r-vdp commented

Fixed in #261778