Missing username in spyder PATH when launched from desktop

When I launch spyder from deskop icon, the path that supposed to be /etc/profiles/per-user/toni/bin is missing my name and just be /etc/profiles/per-user//bin. Can anyone confirm this? See the No. 7 output. When I run this in terminal, everything is in order.

Python 3.13.12 (main, Feb  3 2026, 17:53:27) [GCC 14.3.0]
Type "copyright", "credits" or "license" for more information.

IPython 9.11.0 -- An enhanced Interactive Python. Type '?' for help.

import os

path = os.environ.get("PATH", "")
paths = path.split(":")

print("\n=== PATH ENTRIES ===\n")
for i, p in enumerate(paths, 1):
    print(f"{i:02d}. {p}")

print("\n=== SUMMARY ===")
print(f"Total entries: {len(paths)}")

=== PATH ENTRIES ===

01. /home/toni/.local/share/zinit/polaris/bin
02. /etc/profiles/per-user/toni/bin
03. /run/wrappers/bin
04. /home/toni/.nix-profile/bin
05. /nix/profile/bin
06. /home/toni/.local/state/nix/profile/bin
07. /etc/profiles/per-user//bin
08. /nix/var/nix/profiles/default/bin
09. /run/current-system/sw/bin
10. /home/toni/.zsh/plugins/zinit

=== SUMMARY ===
Total entries: 10

Fun! This sounds like a typical case of a mismatch between your user session and what you get after running your shell init files.

What DE/WM do you use, are you using the wayland session if you’re using a DE that supports both X11 and wayland, and how do you start it? What are the contents of your ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.bash_login, ~/.xprofile, and ~/.xinitrc (assuming bash, if you use a different shell we can go dig up which files that one uses)?

I use typical KDE Wayland with zsh. I see nothing special in my .zshrc

source /etc/nixos/dotfiles/zsh/.p10k.zsh

typeset -U path cdpath fpath manpath
for profile in ${(z)NIX_PROFILES}; do
  fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
done

HELPDIR="/nix/store/lm0ys7aqysrm12blzk5n0p25vvn16g8x-zsh-5.9/share/zsh/$ZSH_VERSION/help"

# Add plugin directories to PATH and fpath
plugin_dirs=(
  zinit
)
for plugin_dir in "${plugin_dirs[@]}"; do
  path+="/home/toni/.zsh/plugins/$plugin_dir"
  fpath+="/home/toni/.zsh/plugins/$plugin_dir"
done
unset plugin_dir plugin_dirs


autoload -Uz compinit
fpath=(${(ou)fpath})
if [[ ! -s ${ZDOTDIR:-$HOME}/.zcompdump || \
      /run/current-system/sw -nt ${ZDOTDIR:-$HOME}/.zcompdump ]]; then
  compinit
  zcompile ${ZDOTDIR:-$HOME}/.zcompdump 2>/dev/null
else
  compinit -C
fi

source /nix/store/vsif3vby6r992pnbc0j0ynafrdgsb2pq-zsh-autosuggestions-0.7.1/share/zsh-autosuggestions/zsh-autosuggestions.zsh
ZSH_AUTOSUGGEST_STRATEGY=(history)


# Source plugins
plugins=(
  zinit/share/zinit/zinit.zsh
)
for plugin in "${plugins[@]}"; do
  [[ -f "/home/toni/.zsh/plugins/$plugin" ]] && source "/home/toni/.zsh/plugins/$plugin"
done
unset plugin plugins

# History options should be set in .zshrc and after oh-my-zsh sourcing.
# See https://github.com/nix-community/home-manager/issues/177.
HISTSIZE="10000"
SAVEHIST="10000"

HISTFILE="/home/toni/.local/share/zsh/history"
mkdir -p "$(dirname "$HISTFILE")"

setopt HIST_FCNTL_LOCK

# Enabled history options
enabled_opts=(
  HIST_IGNORE_ALL_DUPS HIST_IGNORE_DUPS HIST_IGNORE_SPACE SHARE_HISTORY
)
for opt in "${enabled_opts[@]}"; do
  setopt "$opt"
done
unset opt enabled_opts

# Disabled history options
disabled_opts=(
  APPEND_HISTORY EXTENDED_HISTORY HIST_EXPIRE_DUPS_FIRST HIST_FIND_NO_DUPS
  HIST_SAVE_NO_DUPS
)
for opt in "${disabled_opts[@]}"; do
  unsetopt "$opt"
done
unset opt disabled_opts

eval "$(/nix/store/irlbxkxm3rs17rvj42chis3ip8679hqh-direnv-2.37.1/bin/direnv hook zsh)"

source /nix/store/daw80f1pj1j6ic96zgswfvp30shxz9wl-zsh-syntax-highlighting-0.8.0/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_HIGHLIGHTERS+=()



source /nix/store/iqnajc1a1xxc273lg1nd0akgm9k8mmay-zsh-history-substring-search-1.1.0/share/zsh-history-substring-search/zsh-history-substring-search.zsh
bindkey "^[[A" history-substring-search-up
bindkey "^[[B" history-substring-search-down

# powerlevel10k — sync, harus duluan
zinit ice depth=1
zinit light romkatv/powerlevel10k

# plugins turbo — load setelah prompt muncul
zinit ice wait lucid
zinit snippet OMZ::plugins/git/git.plugin.zsh

zinit ice wait lucid
zinit snippet OMZ::plugins/fzf/fzf.plugin.zsh

zinit ice wait lucid
zinit light IngoMeyer441/zsh-easy-motion

export GPG_TTY=$TTY

Here is the relevant snippet from home.nix

  # ZSH and OMZ
  programs.zsh = {
    enable = true;
    enableCompletion = true;

    completionInit = ''
      autoload -Uz compinit
      fpath=(''${(ou)fpath})
      if [[ ! -s ''${ZDOTDIR:-$HOME}/.zcompdump || \
            /run/current-system/sw -nt ''${ZDOTDIR:-$HOME}/.zcompdump ]]; then
        compinit
        zcompile ''${ZDOTDIR:-$HOME}/.zcompdump 2>/dev/null
      else
        compinit -C
      fi
    '';

    autosuggestion.enable = true;
    syntaxHighlighting.enable = true;
    historySubstringSearch = {
      enable = true;
      searchUpKey = ["^[[A"];   # arrow up
      searchDownKey = ["^[[B"]; # arrow down
    };

    plugins = [
      {
        name = "zinit";
        src = pkgs.zinit;
        file = "share/zinit/zinit.zsh";
      }
    ];

    initContent = lib.mkMerge [
      (lib.mkBefore ''
        source /etc/nixos/dotfiles/zsh/.p10k.zsh
      '')

      (lib.mkAfter ''
        # powerlevel10k — sync, harus duluan
        zinit ice depth=1
        zinit light romkatv/powerlevel10k

        # plugins turbo — load setelah prompt muncul
        zinit ice wait lucid
        zinit snippet OMZ::plugins/git/git.plugin.zsh

        zinit ice wait lucid
        zinit snippet OMZ::plugins/fzf/fzf.plugin.zsh

        zinit ice wait lucid
        zinit light IngoMeyer441/zsh-easy-motion

        export GPG_TTY=$TTY
      '')
    ];

    history = {
      size = 10000;
      path = "${config.xdg.dataHome}/zsh/history";
      ignoreAllDups = true;
    };
  };

The issue isn’t that zsh is misconfigured, it’s that I suspect it loads more environment variables than KDE does, so spyder shows you what your “real” environment looks like.

That said, no indication of that in your .zshrc; perhaps it’s your terminal config, or something in the global zsh rcfiles.

Do you do anything special to launch KDE? Is it the wayland session?

I use KDE Wayland as is. Just turn on my PC, log in and got wayland as session.

    # Enable the KDE Plasma Desktop Environment.
    desktopManager.plasma6.enable = true;
    displayManager = {
      sddm = {
        enable = true;
        wayland.enable = true;
      };
    };

Eventually I fix this with home-manager

    sessionPath = [
      "${config.home.profileDirectory}/bin" # fix spyder doesn't see git
    ];