i’ve been configuring my system and when i checked my PATH there were duplicates. so i started trying to deduplicate it for tidiness, so far i’ve been messing around with 90-user.conf and .profile files. i also did some other stuff in my nushell configs but that’s because of how nushell works, so i don’t have much doubts about that.

i’ll try to be as clear, concise as possible, but since i’ve started doing this stuff very recently i might not exactly know where to aim my question. so i guess i have doubts regarding if this is a correct way to handle PATH declaration and deduplication. from what i understand, i need to define it in various places because having a correct path depends largely on where you’re inheriting it. so maybe your GUI session has a proper PATH, but if you log in through a TTY or similar you might have a different one. also different files also add their own stuff. so should i only care about these 2 files to have a proper file or is there something else i should keep in mind? is the reasoning correct?

if you need some other file just let me know and i’ll share it if it’s useful. below is system information in case it’s relevant.

❯ fastfetch

╭─ システム                    [ghost-user]
│
│ os Fedora Linux 43
│ kernel 7.2.13-100.fc43.x86_64
│ age 345 days
│ uptime 8 hours, 10 mins
│ shell nushell 0.99.1
│ de GNOME 49.10
│ wm Mutter (Wayland)
│ cpu AMD Ryzen 5 5600G 4.46 GHz
│ memory 5.23 GiB / 7.05 GiB (74%)
│
│                                過去を殺せ
╰──────────────────────────────────────────

#90-user.conf

EDITOR=hx
BROWSER=firefox
XDG_DATA_HOME=$HOME/.local/share
XDG_CONFIG_HOME=$HOME/.config
XDG_CACHE_HOME=$HOME/.cache

PATH=$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.opencode/bin:/usr/local/go/bin${PATH:+:$PATH}
PKG_CONFIG_PATH=/usr/lib64/pkgconfig
#.profile

export _DOTFILES_PROFILE_SOURCED=1

case ":$PATH:" in *":$HOME/.opencode/bin:"*) ;; *) PATH="$HOME/.opencode/bin:$PATH" ;; esac

[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"

case ":$PATH:" in *":/usr/local/go/bin:"*) ;; *) PATH="$PATH:/usr/local/go/bin" ;; esac

if [ -n "$PATH" ]; then
    pinned=""
    IFS_OLD=$IFS
    IFS=:
    for _d in $PATH; do
        [ -z "$_d" ] && continue
        case ":$pinned:" in *":$_d:"*) continue ;; esac
        [ "$_d" = "$HOME/.local/bin" ] && continue
        pinned="${pinned}${pinned:+:}${_d}"
    done
    IFS=$IFS_OLD
    unset _d
    export PATH="$HOME/.local/bin:$pinned"
fi

verification:

#bash

❯ echo "$PATH" | tr ':' '\n'
/home/ghost_user/.local/bin
/usr/lib64/ccache
/home/ghost_user/.cargo/bin
/home/ghost_user/.opencode/bin
/usr/local/go/bin
/usr/local/bin
/usr/bin
#nushell

❯ $env.PATH
╭───┬────────────────────────────────╮
│ 0 │ /home/ghost_user/.local/bin    │
│ 1 │ /usr/lib64/ccache              │
│ 2 │ /home/ghost_user/.cargo/bin    │
│ 3 │ /home/ghost_user/.opencode/bin │
│ 4 │ /usr/local/go/bin              │
│ 5 │ /usr/local/bin                 │
│ 6 │ /usr/bin                       │
╰───┴────────────────────────────────╯
  • chgxvjh [comrade/them, he/him]@hexbear.net
    link
    fedilink
    English
    arrow-up
    2
    ·
    15 hours ago

    I don’t really get what you are doing.

    You understanding of PATH sounds basically correct.

    My advice would be to document everything you change. That way you actually learn more and also always have information on hand that allow you to unscrew your mistakes.

    How should documentation look like? Original version of a config file, what you change, and why you change it. All the commands you run. Put it in markdown files in a git repo or something unless you already have a knowledge base than use that.

    • ghost_laptop@lemmy.mlOP
      link
      fedilink
      arrow-up
      2
      ·
      13 hours ago

      that is exactly what i was trying to do, in fact i forst configured everyghing ans while i was trying to write the .md i thought maybe i either didnt understand or i was missing something. this is part of my chezmoi managed dotfiles. my doubts started because previosly i thougth these two files habdled all of path, but actually various files add different parts of path. so maybe i should not used these two files to habdle path, or maybe yes but i was missing something, etc. essentially i wanted human help besides old forum posts about this .