FS#66339 - [java-runtime-common] ash profile script doesn't check if $PATH variable contains jvm path

Attached to Project: Arch Linux
Opened by Jakub Nowak (MrQubo) - Tuesday, 21 April 2020, 14:55 GMT
Last edited by freswa (frederik) - Wednesday, 18 January 2023, 17:34 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Levente Polyak (anthraxx)
freswa (frederik)
Architecture All
Severity Very Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 5
Private No

Details

Description:

The `profile_jre.sh` script adds new path to the $PATH env variable but it doesn't check if this path isn't already there.
The `profile_jre.csh` doesn't check this as well.

Note that `/etc/profile` from `core/filesystem` (https://git.archlinux.org/svntogit/packages.git/tree/trunk/profile?h=packages/filesystem&id=b436e401c6b2115110b99b679d386b4da2ec192f) does this properly using `appendpath()`.


I'm using tmux and the jvm path ends up in $PATH twice.
This task depends upon

Closed by  freswa (frederik)
Wednesday, 18 January 2023, 17:34 GMT
Reason for closing:  Fixed
Additional comments about closing:  java-*-common-3-4
Comment by Levente Polyak (anthraxx) - Thursday, 23 April 2020, 18:33 GMT
what does tmux have to do with that? I'm using tmux as well and only end up with a single /usr/lib/jvm/default/bin in my $PATH. None of the profile scripts do such checks, only login shells are supposed to read the profile, once.
Comment by Jakub Nowak (MrQubo) - Friday, 24 April 2020, 17:56 GMT
How are you starting tmux? I've just checked it on a completely fresh archlinux and after I start it by simply invoking `tmux` command the jvm path is duplicated.
Comment by Jakub Nowak (MrQubo) - Friday, 24 April 2020, 17:58 GMT
Do you suggest I should report this as an issue to tmux developers?
Comment by Levente Polyak (anthraxx) - Friday, 24 April 2020, 20:56 GMT
try something like

set -g default-shell /usr/bin/zsh
set -g default-command /usr/bin/zsh

in your config?
Comment by Jakub Nowak (MrQubo) - Saturday, 25 April 2020, 08:56 GMT
Oh, I've always used only `default-shell` but it seems that `default-shell` should only be used when using tmux as login shell. `default-command` fixed the issue of duplicate path entries for me.

I still think that it will be more robust to check if the path isn't already present in the $PATH env variable as default `/etc/profile` does.
Comment by B (4xfn) - Thursday, 31 December 2020, 18:09 GMT
I use login shells by default because of some logic in .bash_logout/.zlogout that should run after each shell and also noticed the duplicate /usr/lib/jvm/default/bin PATH entries coming from /etc/profile.d/jre.sh. To avoid this the perl package uses the `append_path` method from the /etc/profile script: https://github.com/archlinux/svntogit-packages/blob/84bd26259d8177aae3817fd1fcf8b507f0e05bb1/trunk/perlbin.sh#L5-L11 so using `append_path /usr/lib/jvm/default/bin` instead of `export PATH=${PATH}:/usr/lib/jvm/default/bin` should fix this issue.
Comment by Scott B (arglebargle) - Friday, 10 December 2021, 16:24 GMT
re: "None of the profile scripts do such checks, only login shells are supposed to read the profile, once."

@anthraxx /etc/profile's 'append_path' function exists now to solve exactly this issue, it's available to every script run from /etc/profile.d.

I made the following edits to profile_jre.sh on my local machine:

-export PATH=${PATH}:/usr/lib/jvm/default/bin
+append_path '/usr/lib/jvm/default/bin'
+export PATH
Comment by Codrut Constantin Gusoi (sdwolfz) - Sunday, 25 September 2022, 11:10 GMT
I've debugged and proposed a change to a similar issue here: https://gitlab.manjaro.org/packages/core/filesystem/-/issues/4

Granted that one needs to be prepended, not appended, but I would like to see this change implemented as well in `profile_jre.sh`

```
append_path '/usr/lib/jvm/default/bin'
export PATH
```

Anything holding this back? It seems straightforward to me.
Comment by Arvid Norlander (VorpalGun) - Wednesday, 18 January 2023, 17:17 GMT
I also ran into to this today. Any progress on it? Like the previous commenter said, this seems straight forward to fix using the append_path provided by /etc/profile.

Loading...