Oh-my-posh error with fish

I set up fish using home-manager, and when I opened fish recently, I started getting an error:

fish: Unknown command: /nix/store/4x8sgjbkslayh92vyijh5hjhr9jvahqy-oh-my-posh-26.8.0/bin/oh-my-posh
~/.cache/oh-my-posh/init.26.8.0.c39c0f22099034f8..fish (line 33):
    $_omp_executable print $argv[1] \
    ^~~~~~~~~~~~~~~^
in function '_omp_get_prompt' with arguments 'primary --cleared=false'
        called on line 1 of file ~/.cache/oh-my-posh/init.26.8.0.c39c0f22099034f8..fish
in command substitution
        called on line 102 of file ~/.cache/oh-my-posh/init.26.8.0.c39c0f22099034f8..fish
in function 'fish_prompt'
in command substitution
fish: Unknown command: /nix/store/4x8sgjbkslayh92vyijh5hjhr9jvahqy-oh-my-posh-26.8.0/bin/oh-my-posh
~/.cache/oh-my-posh/init.26.8.0.c39c0f22099034f8..fish (line 33):
    $_omp_executable print $argv[1] \
    ^~~~~~~~~~~~~~~^
in function '_omp_get_prompt' with arguments 'right'
        called on line 1 of file ~/.cache/oh-my-posh/init.26.8.0.c39c0f22099034f8..fish
in command substitution
        called on line 120 of file ~/.cache/oh-my-posh/init.26.8.0.c39c0f22099034f8..fish
in function 'fish_right_prompt'
in command substitution

I don’t know anything about this program, but the cached fish script is referencing a deleted binary in your nix store, so it was probably garbage collected(?)

Maybe you want to regenerate this script somehow.

After removing oh-my-posh from home-manager, the error disappeared

Hi

I’m having this same issue, right after running garbage collect on packages older than 7 days, but I don’t use home-manager. It’s all in my configuration.nix file.

In an attempt to fix it, I commented out all oh-my-posh and fish related lines from configuration.nix, rebuilt, ran garbage-collect again, but without a time limit and then uncommented the same lines, rebuilt (with several restarts in between, although I am including the switch argument when rebuilding), but I’m still getting the same error. Is there a way to force fish to regenerate somehow?

Any help would be appreciated.

The terminal output and the configuration.nix file are below.

Thanks!

edit: I switched to bash in the meantime, to check that the issue isn’t oh-my-posh, and it’s working fine with bash, so it seems the issue was with fish and whatever cached version of oh-my-posh it cannot find.
While writing this edit, I was doing some more testing and in bash I ran exec fish, which started the simple fish shell.
I executed oh-my-posh cache clear.
I then enabled the oh-my-posh promptInit for fish again and executed fish again from inside the bash shell and it ran fine.
So, lastly, I made fish the default shell again and the oh-my-posh integration seems to be working fine.

I can’t say for sure if running the oh-my-posh cache clear did anything or if executing fish from within bash did, but if anyone else encounters this issue, I hope it helps and you don’t end up going as far as garbage-collecting everything in hopes that it helps, like I did :slight_smile:

Terminal

fish: Unknown command: /nix/store/b67118lwnvvc8dsr4w28l5cm9ffx540g-oh-my-posh-26.23.6/bin/oh-my-posh
~/.cache/oh-my-posh/init.14695981039346656037.fish (line 30): 
    $_omp_executable print $argv[1] \
    ^~~~~~~~~~~~~~~^
in function '_omp_get_prompt' with arguments 'primary --cleared=false'
	called on line 1 of file ~/.cache/oh-my-posh/init.14695981039346656037.fish
in command substitution
	called on line 99 of file ~/.cache/oh-my-posh/init.14695981039346656037.fish
in function 'fish_prompt'
in command substitution
fish: Unknown command: /nix/store/b67118lwnvvc8dsr4w28l5cm9ffx540g-oh-my-posh-26.23.6/bin/oh-my-posh
~/.cache/oh-my-posh/init.14695981039346656037.fish (line 30): 
    $_omp_executable print $argv[1] \
    ^~~~~~~~~~~~~~~^
in function '_omp_get_prompt' with arguments 'right'
	called on line 1 of file ~/.cache/oh-my-posh/init.14695981039346656037.fish
in command substitution
	called on line 117 of file ~/.cache/oh-my-posh/init.14695981039346656037.fish
in function 'fish_right_prompt'
in command substitution

configuration.nix file

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Bootloader.
  boot.loader.grub.enable = true;
  boot.loader.grub.device = "/dev/sda";
  boot.loader.grub.useOSProber = true;

  # Use latest kernel.
  boot.kernelPackages = pkgs.linuxPackages_latest;

  # Enable NTFS support at boot
  boot.supportedFilesystems = [ "ntfs" ];

    fileSystems."/run/media/greyhound/Void" =
    { device = "/dev/disk/by-uuid/000064CF0064CCEA";
      fsType = "ntfs-3g"; 
      options = [ "rw" "uid=1000" "nofail" "x-gvfs-show"];
    };

  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Europe/Bucharest";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_US.UTF-8";
    LC_IDENTIFICATION = "en_US.UTF-8";
    LC_MEASUREMENT = "en_US.UTF-8";
    LC_MONETARY = "en_US.UTF-8";
    LC_NAME = "en_US.UTF-8";
    LC_NUMERIC = "en_US.UTF-8";
    LC_PAPER = "en_US.UTF-8";
    LC_TELEPHONE = "en_US.UTF-8";
    LC_TIME = "en_US.UTF-8";
  };
  
  security.pam.services.gdm.enableGnomeKeyring = true;
  security.pam.services.login.enableGnomeKeyring = true;
  services.gnome.gnome-keyring.enable = true;


  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the GNOME Desktop Environment.
  services.displayManager.gdm.enable = true;
  services.desktopManager.gnome.enable = true;

  # Enable Num Lock at startup
  services.displayManager.sddm.autoNumlock = true;

  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "us";
    variant = "";
  };

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  services.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;
  
  services.input-remapper = {
    enable = true;
  };
  
  services.urserver = {
    enable = true;
  };
  
  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.greyhound = {
    isNormalUser = true;
    description = "Greyhound";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
    #  thunderbird
    ];
  };

  users.defaultUserShell = pkgs.fish;
  
  # Enable automatic login for the user.
  services.displayManager.autoLogin.enable = true;
  services.displayManager.autoLogin.user = "greyhound";

  # Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229
  systemd.services."getty@tty1".enable = false;
  systemd.services."autovt@tty1".enable = false;

  # Install firefox.
  programs.firefox = {
    package = pkgs.firefox;
    enable = true;
    nativeMessagingHosts.packages = [ pkgs.firefoxpwa ];
  };

  #install Steam
  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
    dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
    localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers
  };

  programs.nh = {
    enable = true;
  };
  
  fonts.fontconfig = {
    enable = true;
    # defaultFonts.emoji = [ "Noto Color Emoji" ];
    defaultFonts.emoji = [ "Apple Color Emoji" ];
  };
  
  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  nix.settings.experimental-features = [ "nix-command" ];
  nix.settings.download-buffer-size = 671088640;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    #  vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    #  wget
    firefoxpwa
    vim
    neovim
    alacritty
    vlc
    mpv
    wget
    git
    vscode
    qbittorrent
    beeper
    wine
    # albert
    # valent
    # rustdesk
    #  spacedrive
    rustup
    #  python3Full
    discord
    emacs
    libreoffice-qt6-fresh
    hunspell
    hunspellDicts.en_US
    hunspellDicts.ro_RO
    emote
    smplayer
    distrobox
    #  helix
    #  kitty
    #  foot
    #  ghostty
    #  guake
    # tabby
    #  terminator
    #  tilda
    #  warp
    #  warp-terminal
    #  waveterm
    #  zed-editor
    neofetch
    fastfetch
    nil
    nixd
    #  notion-app-enhanced
    #  obsidian
    nerdfetch
    oh-my-posh
    nerd-fonts.symbols-only
    nerd-fonts.hack
    # noto-fonts-color-emoji
    vscodium
    junction
    browsers
    # stremio
    noip
    file
    # sublime4
    # urserver
    # ulauncher
    ### Gnome
    gnome-menus
    gnome-tweaks
    gnome-browser-connector
    gnomeExtensions.gsconnect
    gnomeExtensions.arcmenu
    gnomeExtensions.just-perfection
    gnomeExtensions.freon
    gnomeExtensions.bing-wallpaper-changer  
    gnomeExtensions.dash-to-panel
    gnomeExtensions.tray-icons-reloaded
    # nautilus-python
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  programs.fish = {
    enable = true;
    promptInit = "oh-my-posh init fish | source";

  };
  
  programs.xfconf = {
    enable = true;
  };
  
  # Enable AppImage support
  programs.appimage = {
    enable = true;                 # Enable AppImage integration
    binfmt = true;                 # Enable AppImage binary format support
  };
  
  programs.direnv = {
    enable = true;
    enableFishIntegration = true;
  };
 
  virtualisation.podman = {
   enable = true;
   dockerCompat = true;
  };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  networking.firewall = rec {
    allowedTCPPortRanges = [ { from = 1714; to = 1764; } { from = 9510; to = 9512; } { from = 11470; to = 11470; } { from = 12470; to = 12470; } { from = 56852; to = 56852;} ];
    allowedUDPPortRanges = allowedTCPPortRanges;
  };  
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

 # Disable suspend of Toslink output to prevent audio popping.
  services.pipewire.wireplumber.extraConfig."99-disable-suspend" = {
    "monitor.alsa.rules" = [
      {
        matches = [
          {
            "node.name" = "alsa_output.pci-0000_00_1b.0.analog-stereo";
          }
        ];
        actions = {
          update-props = {
            "session.suspend-timeout-seconds" = 0;
          };
        };
      }
    ];
  };
  
  services.flatpak.enable = true;

  services.gvfs.enable = true; # Mount, trash, and other functionalities
  services.tumbler.enable = true; # Thumbnail support for images

  services.gnome.sushi.enable = true;

  xdg.mime.defaultApplications = {
    "application/x-bittorrent" = "qbittorrent.desktop";
  };

  system.autoUpgrade.enable = true;
  system.autoUpgrade.allowReboot = true;
  system.autoUpgrade.channel = "https://channels.nixos.org/nixos-unstable";

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "25.05"; # Did you read the comment?

}

drop the cache (i.e. rm -rf ~/.cache/oh-my-posh)? Assuming sanity, the cache will be rebuilt.

Thanks.
I’ll be sure to try this first if it happens again.