Setting system-wide PATH does not work for me

Hi all,

I tried to change my system-wide path, but for some reason it does not work for me. I installed a few binaries in a subfolder under /opt, and want to add this subfolder to the system path. I created 2 new files under /etc/profile.d/ - one is the .sh variant, the other is the .csh variant. The contents are as follows:

[ -d /opt/JLink ] && append_path '/opt/JLink'

export PATH

and

[ -d /opt/JLink ] && setenv PATH ${PATH}:/opt/JLink

Both files are owned by root and have permissions 644. The directory exists and is spelled correctly. However, when I reboot/relogin, my path only shows:

╭─[email protected] in ~ took 74ms
╰─λ echo $PATH
/usr/local/sbin /usr/local/bin /usr/bin /usr/bin/site_perl /usr/bin/vendor_perl /usr/bin/core_perl

I also tried with creating the folder ~/.config/environment.d/ and then adding a file path.conf with the contents PATH=${PATH}:/opt/JLink as per the Arch Wiki, but that did not work either.

I am using Garuda Dragonized KDE edition and my shell is Fisch. (I also want the extended PATH to be available for other applications outside of Fisch).. Here is my system info:

inxi output
System:    Kernel: 5.11.10-zen1-1-zen x86_64 bits: 64 compiler: gcc v: 10.2.0
           parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen root=UUID=99d0c990-60c6-4faf-86ee-17a4aa79cc5e rw
           [email protected] quiet splash rd.udev.log_priority=3 vt.global_cursor_default=0
           systemd.unified_cgroup_hierarchy=1 resume=UUID=cd59ffac-afc3-40a2-bb41-7efe054d6ff4 loglevel=3
           Desktop: KDE Plasma 5.21.3 tk: Qt 5.15.2 info: latte-dock wm: kwin_x11 vt: 1 dm: SDDM Distro: Garuda Linux
           base: Arch Linux
Machine:   Type: Laptop System: Dell product: XPS 15 9550 v: N/A serial: <filter> Chassis: type: 9 serial: <filter>
           Mobo: Dell model: 0Y9N5X v: A08 serial: <filter> UEFI: Dell v: 1.14.0 date: 02/13/2020
Battery:   ID-1: BAT0 charge: 84.0 Wh (100.0%) condition: 84.0/84.0 Wh (100.0%) volts: 12.4 min: 11.4 model: SMP DELL 1P6KD54
           type: Li-poly serial: <filter> status: Full
           Device-1: hid-0003:256F:C652.0008-battery model: 3Dconnexion Universal Receiver serial: N/A charge: N/A status: N/A
CPU:       Info: Quad Core model: Intel Core i7-6700HQ bits: 64 type: MT MCP arch: Skylake-S family: 6 model-id: 5E (94)
           stepping: 3 microcode: E2 cache: L2: 6 MiB
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 41599
           Speed: 3495 MHz min/max: 800/3500 MHz Core speeds (MHz): 1: 3495 2: 3201 3: 3266 4: 3158 5: 3428 6: 3196 7: 3285
           8: 3141
           Vulnerabilities: Type: itlb_multihit status: KVM: VMX disabled
           Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
           Type: mds mitigation: Clear CPU buffers; SMT vulnerable
           Type: meltdown mitigation: PTI
           Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl and seccomp
           Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization
           Type: spectre_v2 mitigation: Full generic retpoline, IBPB: conditional, IBRS_FW, STIBP: conditional, RSB filling
           Type: srbds mitigation: Microcode
           Type: tsx_async_abort mitigation: Clear CPU buffers; SMT vulnerable
Graphics:  Device-1: Intel HD Graphics 530 vendor: Dell XPS 15 9550 driver: i915 v: kernel bus-ID: 00:02.0 chip-ID: 8086:191b
           class-ID: 0300
           Device-2: NVIDIA GM107M [GeForce GTX 960M] vendor: Dell XPS 15 9550 driver: nvidia v: 460.67
           alternate: nouveau,nvidia_drm bus-ID: 01:00.0 chip-ID: 10de:139b class-ID: 0302
           Device-3: Microdia Integrated_Webcam_HD type: USB driver: uvcvideo bus-ID: 1-12:5 chip-ID: 0c45:6713 class-ID: 0e02
           Display: x11 server: X.Org 1.20.10 compositor: kwin_x11 driver: loaded: intel,nvidia unloaded: modesetting,nouveau
           alternate: fbdev,nv,vesa display-ID: :0 screens: 1
           Screen-1: 0 s-res: 5120x1440 s-dpi: 96 s-size: 1353x380mm (53.3x15.0") s-diag: 1405mm (55.3")
           Monitor-1: DP1-1 res: 2560x1440 hz: 60 dpi: 108 size: 600x340mm (23.6x13.4") diag: 690mm (27.2")
           Monitor-2: DP1-2 res: 2560x1440 hz: 60 dpi: 108 size: 600x340mm (23.6x13.4") diag: 690mm (27.2")
           OpenGL: renderer: Mesa Intel HD Graphics 530 (SKL GT2) v: 4.6 Mesa 21.0.1 direct render: Yes
Audio:     Device-1: Intel 100 Series/C230 Series Family HD Audio vendor: Dell XPS 15 9550 driver: snd_hda_intel v: kernel
           bus-ID: 00:1f.3 chip-ID: 8086:a170 class-ID: 0403
           Device-2: Focusrite-Novation Scarlett 2i2 Camera type: USB driver: snd-usb-audio,usb-storage bus-ID: 3-2.1:3
           chip-ID: 1235:8210 class-ID: 0806 serial: <filter>
           Device-3: Microsoft LifeCam Studio type: USB driver: hid-generic,snd-usb-audio,usbhid,uvcvideo bus-ID: 3-2.3.3.1:9
           chip-ID: 045e:0772 class-ID: 0300
           Device-4: Realtek USB Audio type: USB driver: snd-usb-audio bus-ID: 3-2.3.4:8 chip-ID: 0bda:402e class-ID: 0102
           serial: <filter>
           Sound Server-1: ALSA v: k5.11.10-zen1-1-zen running: yes
           Sound Server-2: JACK v: 1.9.17 running: no
           Sound Server-3: PulseAudio v: 14.2 running: yes
           Sound Server-4: PipeWire v: 0.3.24 running: no
Network:   Device-1: Intel Wireless-AC 9260 driver: iwlwifi v: kernel port: e000 bus-ID: 02:00.0 chip-ID: 8086:2526
           class-ID: 0280
           IF: wlp2s0 state: up mac: <filter>
           Device-2: Realtek RTL8153 Gigabit Ethernet Adapter type: USB driver: r8152 bus-ID: 4-2.4:7 chip-ID: 0bda:8153
           class-ID: 0000 serial: <filter>
           IF: enp11s0u2u4 state: up speed: 1000 Mbps duplex: full mac: <filter>
Bluetooth: Device-1: Intel Wireless-AC 9260 Bluetooth Adapter type: USB driver: btusb v: 0.8 bus-ID: 1-4:3 chip-ID: 8087:0025
           class-ID: e001
           Report: ID: hci0 state: up address: <filter>
Drives:    Local Storage: total: 476.94 GiB used: 118.65 GiB (24.9%)
           SMART Message: Unable to run smartctl. Root privileges required.
           ID-1: /dev/nvme0n1 maj-min: 259:0 model: Acer VT500M M.2 NVME 512G size: 476.94 GiB block-size: physical: 512 B
           logical: 512 B speed: 31.6 Gb/s lanes: 4 rotation: SSD serial: <filter> rev: S0614B0G temp: 38.9 C scheme: GPT
           ID-2: /dev/sda maj-min: 8:0 type: USB model: Scarlett Welcome Disk size: 192 KiB block-size: physical: 512 B
           logical: 512 B serial: <filter> rev: 0.10 scheme: MBR
           SMART Message: Unknown USB bridge. Flash drive/Unsupported enclosure?
Partition: ID-1: / raw-size: 442.34 GiB size: 442.34 GiB (100.00%) used: 118.65 GiB (26.8%) fs: btrfs dev: /dev/nvme0n1p2
           maj-min: 259:2
           ID-2: /boot/efi raw-size: 260 MiB size: 256 MiB (98.46%) used: 546 KiB (0.2%) fs: vfat dev: /dev/nvme0n1p1
           maj-min: 259:1
           ID-3: /home raw-size: 442.34 GiB size: 442.34 GiB (100.00%) used: 118.65 GiB (26.8%) fs: btrfs dev: /dev/nvme0n1p2
           maj-min: 259:2
           ID-4: /var/log raw-size: 442.34 GiB size: 442.34 GiB (100.00%) used: 118.65 GiB (26.8%) fs: btrfs
           dev: /dev/nvme0n1p2 maj-min: 259:2
           ID-5: /var/tmp raw-size: 442.34 GiB size: 442.34 GiB (100.00%) used: 118.65 GiB (26.8%) fs: btrfs
           dev: /dev/nvme0n1p2 maj-min: 259:2
Swap:      Kernel: swappiness: 10 (default 60) cache-pressure: 75 (default 100)
           ID-1: swap-1 type: partition size: 34.34 GiB used: 0 KiB (0.0%) priority: -2 dev: /dev/nvme0n1p3 maj-min: 259:3
           ID-2: swap-2 type: zram size: 3.9 GiB used: 768 KiB (0.0%) priority: 32767 dev: /dev/zram0
           ID-3: swap-3 type: zram size: 3.9 GiB used: 768 KiB (0.0%) priority: 32767 dev: /dev/zram1
           ID-4: swap-4 type: zram size: 3.9 GiB used: 768 KiB (0.0%) priority: 32767 dev: /dev/zram2
           ID-5: swap-5 type: zram size: 3.9 GiB used: 512 KiB (0.0%) priority: 32767 dev: /dev/zram3
           ID-6: swap-6 type: zram size: 3.9 GiB used: 512 KiB (0.0%) priority: 32767 dev: /dev/zram4
           ID-7: swap-7 type: zram size: 3.9 GiB used: 512 KiB (0.0%) priority: 32767 dev: /dev/zram5
           ID-8: swap-8 type: zram size: 3.9 GiB used: 512 KiB (0.0%) priority: 32767 dev: /dev/zram6
Sensors:   System Temperatures: cpu: 69.0 C mobo: N/A
           Fan Speeds (RPM): cpu: 3220 fan-2: 3215
Info:      Processes: 312 Uptime: 32m wakeups: 2 Memory: 31.21 GiB used: 7.51 GiB (24.0%) Init: systemd v: 247 tool: systemctl
           Compilers: gcc: 10.2.0 clang: 11.1.0 Packages: pacman: 1589 lib: 359 Shell: fish v: 3.2.1 running-in: alacritty
           inxi: 3.3.03

Thanks for your help!

Fish does in fact not read those directories, see this issue for reference:

Possible workarounds include for example this:
https://wiki.archlinux.org/index.php/fish#Modify_.bashrc_to_drop_into_fish

2 Likes

@dr460nf1r3 - Thank you for your answer. But as far as I understand it, the issue you mention should only affect Fish. The modified PATH should still be available to the rest of the applications in my DE, however it is not. This is proven by the output of systemctl show-environment:

systemctl --system show-environment | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
systemctl --user show-environment | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session2

Please notice the perl additions in the second PATH output. I can find those in the 2 files /etc/profile.d/perlbin.[c]sh. So if it works for the perl path, why doesn't it work for my own additions?

You are on fish shell.
Read info.
https://wiki.archlinux.org/index.php/Fish

https://wiki.archlinux.org/index.php/Environment_variables

3 Likes

Hmm...

Thank you all for your answers!

I just noticed that there is a Fish process (via KDE System Monitor), even when I don't have any alacritty terminals open. Do I take this to mean that this process is started by SDDM when I login and it gives my DE its path configuration???

Have you made them executable?

@petsam - doesn't matter if they are. All files in /etc/profile.d/* are sourced from within the /etc/profile script and the only requirement is that they should be readable by the user (as per the following excerpt):

# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
    for profile in /etc/profile.d/*.sh; do
        test -r "$profile" && . "$profile"
    done
    unset profile
fi

When checking permissions of all the files currently inside my /etc/profile.d/ folder, it is a mix between executable and non-executable files. I have reviewed some of them and settings from non-executable files (e.g. perlbin.sh) are being applied. Settings from my own file are not.

P.S. I tested setting the executable bit, same difference.

1 Like

Have you considered any of them?
Have you read Archwiki links?

2 Likes

Yes, I added the directory to the PATH setting in my fish.conf script and it works when I open a new alacritty window. Unfortunately I am performing a very long and computationally-intensive task right now and won't be able to logout/reboot for a few more days to test out if that solves my problem for the whole DE or just when I open a terminal window... We'll see Sunday night or Monday morning.

I hope your tasks go well :smiley: .
When you are available again, explain what you learnt from the EnvVar wiki link. It's all there... :man_shrugging:

Interesting command! What package provides it?

1 Like

Whichever package provides the file /etc/profile. It is a function at the very beginning of the file, which apparently only appends new entries to the path, if they are not already in it.

That's not an answer.

I tried to show you indirectly what the problem is, but you don't seem to get my hidden messages. So,

Stick to Archwiki contents and to programs' documentation (man, help etc.)

If you think you know more than program and distro vendors, then you don't need any help from a tiny small distro support forum.

For example, the above mentioned command is not supposed for you. You are doing assumptions you are not permitted, unless you are experienced and thus... as above, don't need help.

https://wiki.archlinux.org/index.php?search=append_path&title=Special%3ASearch&go=Go
https://man.archlinux.org/search?q=append_path&pkgname=

Read Archwiki and use the suggested methods to assign custom envvars, systemwide, or per-user.
I suggest you undo what you have done for this issue, if you are not sure what is the impact to your system.

Be well!

2 Likes

@petsam - Thank you for pointing this out to me. But your hidden message was hidden too well in this one sentence What package provides it? :wink: Sorry I didn't get it then.

I will go back to the wiki and read it again, maybe enlightenment will strike at some point :yum:

1 Like