Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gimp won't run at all when installed with appman #25

Closed
shlozm opened this issue Dec 22, 2023 · 39 comments
Closed

gimp won't run at all when installed with appman #25

shlozm opened this issue Dec 22, 2023 · 39 comments

Comments

@shlozm
Copy link

shlozm commented Dec 22, 2023

I installed gimp using appman, it won't open at all! No feedback from the terminal just immediately returns to the prompt. The appimage itself works well. I tried running it from the directory appman installs to (.local/share/AppImages/gimp) using ./gimp still nothing,
I also installed google-chrome using appman, that runs just fine.
What can be the problem?

@shlozm
Copy link
Author

shlozm commented Dec 22, 2023

also, I noticed something strange in the symlink that appman puts in .local/bin it links to:/home/sz/.local/share/AppImages//google-chrome/google-chrome, there are 2 slashes after AppImages, the same thing with gimp, it works anyway, just strange...

@shlozm
Copy link
Author

shlozm commented Dec 22, 2023

Update: I manually downloaded and renamed the appimage to gimp without any extension and it ran just fine. As soon as I put a symlink for it named gimp in .local/bin it wouldn't run anymore even when in the appimage directory with ./gimp

I don't understand what could be happening
After removing the symlink it ran again
I renamed the symlink to "himp" and it works, it just doesn't like the name "gimp" as a symlink
renaming to "Gimp" also works

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 22, 2023

I don't know why, but someone else have faced this problem with my JuNest-based AppImages (MPV, GIMP...) on a minimal system ivan-hc/MPV-appimage#12

Sometime the ArchImages have issues in running on some systems using aliases, an it is still a mistery for me.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 22, 2023

Have you tried if the issue is also with VLC, OBS or MPV?

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 22, 2023

Also try to create a script instead of the symlink:

cat >> ~/.local/bin/gimp << 'EOF'
#!/bin/sh
/home/sz/.local/share/AppImages/gimp/gimp "$*"
EOF
chmod a+x ~/.local/bin/gimp

if you say that by downloading it and rename as gimp it works and not aliased, maybe we can try to trick the alias using a script instead.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 23, 2023

I noticed something strange in the symlink that appman puts in .local/bin it links to:/home/sz/.local/share/AppImages//google-chrome/google-chrome, there are 2 slashes after AppImages, the same thing with gimp

is the content of ~/.config/appman/appman-config like this?

.local/share/AppImages

for example, mine is

.cache/Programmi

in ~/.cache because my main CLI is AM, I only do tests with AppMan

@shlozm
Copy link
Author

shlozm commented Dec 24, 2023

Have you tried if the issue is also with VLC, OBS or MPV?

Yes I just tried MPV, same problem . It seems that my Debian 12 system is having this issue with Archimages.

@shlozm
Copy link
Author

shlozm commented Dec 24, 2023

cat >> ~/.local/bin/gimp << 'EOF'
#!/bin/sh
/home/sz/.local/share/AppImages/gimp/gimp "$*"
EOF
chmod a+x ~/.local/bin/gimp

It didn't work! I tried reinstalling gimp using appman , then deleting the symlink and replacing it with a script, it still wouldn't work! I then deleted the script and ran it directly (~/.local/share/AppImages/gimp/gimp) and it works. Very strange...

My script calls the exact same command as I ran in the terminal, but somehow the presence of a file named gimp in .local/bin prevents it from running...

@shlozm
Copy link
Author

shlozm commented Dec 24, 2023

I noticed something strange in the symlink that appman puts in .local/bin it links to:/home/sz/.local/share/AppImages//google-chrome/google-chrome, there are 2 slashes after AppImages, the same thing with gimp

is the content of ~/.config/appman/appman-config like this?

.local/share/AppImages

for example, mine is

.cache/Programmi

in ~/.cache because my main CLI is AM, I only do tests with AppMan

cat .config/appman/appman-config
.local/share/AppImages/

I will try to remove the last slash and see. That's probably the issue.
Yes! fixed now.

@shlozm
Copy link
Author

shlozm commented Dec 24, 2023

I just tried the following in .local/bin
touch gimp
~/.local/share/AppImages/gimp/gimp
it ran
then:
chmod +x gimp
~/.local/share/AppImages/gimp/gimp
and it wouldn't run!
gimp in .local/bin is an empty file, but as soon as it's executable it prevents the Archimage of the same name from running!

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 24, 2023

Normally AppMan uses the command ln -s to create a symlink, what if you use ln -r -s?

In AppMan, change the function at line 766

										function _install_appman_local_patch(){
											sed -i "s# /opt# $APPSPATH#g" ./$arg
											sed -i "s#/opt/#$APPSPATH/#g" ./$arg
											sed -i "s# /usr/local/bin# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/bin# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/local/games# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/games# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/share/applications# $(xdg-user-dir USER)/.local/share/applications#g" ./$arg
											sed -i "s# /usr/local/share/applications# $(xdg-user-dir USER)/.local/share/applications#g" ./$arg
											sed -i "s# /usr/share/pixmaps# $(xdg-user-dir USER)/.local/share/icons#g" ./$arg
											sed -i "s# /usr/local/share/pixmaps# $(xdg-user-dir USER)/.local/share/icons#g" ./$arg
										}

like this

										function _install_appman_local_patch(){
											sed -i "s#ln -s #ln -r -s #g" ./$arg
											sed -i "s# /opt# $APPSPATH#g" ./$arg
											sed -i "s#/opt/#$APPSPATH/#g" ./$arg
											sed -i "s# /usr/local/bin# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/bin# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/local/games# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/games# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/share/applications# $(xdg-user-dir USER)/.local/share/applications#g" ./$arg
											sed -i "s# /usr/local/share/applications# $(xdg-user-dir USER)/.local/share/applications#g" ./$arg
											sed -i "s# /usr/share/pixmaps# $(xdg-user-dir USER)/.local/share/icons#g" ./$arg
											sed -i "s# /usr/local/share/pixmaps# $(xdg-user-dir USER)/.local/share/icons#g" ./$arg
										}

I have added the command sed -i "s#ln -s #ln -r -s #g" ./$arg

Now to install an archimage, maybe gimp itself.

@shlozm
Copy link
Author

shlozm commented Dec 24, 2023

Normally AppMan uses the command ln -s to create a symlink, what if you use ln -r -s?

In AppMan, change the function at line 766

										function _install_appman_local_patch(){
											sed -i "s# /opt# $APPSPATH#g" ./$arg
											sed -i "s#/opt/#$APPSPATH/#g" ./$arg
											sed -i "s# /usr/local/bin# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/bin# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/local/games# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/games# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/share/applications# $(xdg-user-dir USER)/.local/share/applications#g" ./$arg
											sed -i "s# /usr/local/share/applications# $(xdg-user-dir USER)/.local/share/applications#g" ./$arg
											sed -i "s# /usr/share/pixmaps# $(xdg-user-dir USER)/.local/share/icons#g" ./$arg
											sed -i "s# /usr/local/share/pixmaps# $(xdg-user-dir USER)/.local/share/icons#g" ./$arg
										}

like this

										function _install_appman_local_patch(){
											sed -i "s#ln -s #ln -r -s #g" ./$arg
											sed -i "s# /opt# $APPSPATH#g" ./$arg
											sed -i "s#/opt/#$APPSPATH/#g" ./$arg
											sed -i "s# /usr/local/bin# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/bin# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/local/games# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/games# $(xdg-user-dir USER)/.local/bin#g" ./$arg
											sed -i "s# /usr/share/applications# $(xdg-user-dir USER)/.local/share/applications#g" ./$arg
											sed -i "s# /usr/local/share/applications# $(xdg-user-dir USER)/.local/share/applications#g" ./$arg
											sed -i "s# /usr/share/pixmaps# $(xdg-user-dir USER)/.local/share/icons#g" ./$arg
											sed -i "s# /usr/local/share/pixmaps# $(xdg-user-dir USER)/.local/share/icons#g" ./$arg
										}

I have added the command sed -i "s#ln -s #ln -r -s #g" ./$arg

Now to install an archimage, maybe gimp itself.

Just tried. Does not help. The symlink is fine just seems to be the same issue...

(This what the symlink looks like in 'lsd' gimp ⇒ ../share/AppImages/gimp/gimp)

@shlozm
Copy link
Author

shlozm commented Dec 24, 2023

I just tried moving the AppImage itself named 'gimp' into .local/bin and it wouldn't run, even though there was no other file named 'gimp' anywhere else, I renamed it to 'Gimp' and it runs. So the problem is the AppImage having the same name as the executable that's in the AppImage being in .local/bin

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 24, 2023

This should not be the way that they must work, they should be readi to use out of the box.

I have tested them on Debian, Arch Linux and Fedora and they work.

@kenderipa from the issue above have a minimal Debian system with JWM, I don't know what is your configuration, but I'm sure that there is some basic stuff that is missing on the host system. Something about a different configuration of aliases and $PATH managing. It is not related to the AppImages themself. A missing system requirement that we have not. Maybe the .bashrc file or something. I don't know what is managing that. I have also wrote a post on Reddit looking for an answer.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 24, 2023

For example, this is my ~/.profile file:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
	. "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

export QT_QPA_PLATFORMTHEME=qt5ct
export QT_STYLE_OVERRIDE=kvantum

and this is my ~/.bashrc:

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
	# We have color support; assume it's compliant with Ecma-48
	# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
	# a case would tend to support setf rather than setaf.)
	color_prompt=yes
    else
	color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    #alias grep='grep --color=auto'
    #alias fgrep='fgrep --color=auto'
    #alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi
export PATH=$PATH:$(xdg-user-dir USER)/.local/bin

Apart the last lines, they are the defaoult ones of my Debian Testing installation with XFCE4 and lightdm.

@shlozm @kenderipa you can compare them using https://www.diffchecker.com

I don't know if that would help to understand what is happens on your systems.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 24, 2023

Additional detail, I've opened three of my Appimages, Chromium and Ocenaudio (deb-based) and GIMP (archimage), the latter is the only one that mounts the internal proot (not installed on my system).

JuNest (the Arch Linux container that runs GIMP, MPV and other archimages), if installed normally, rely on the following isolation systems, depending on the mode you run it:

  • Normal mode uses "bubblewrap" (in $PATH "bwrap") and works with Linux's namespaces;
  • Proot mode uses "proot".

Normally, both of the above are builtin, but proot is the only one I included in my archimages.

To made tha Archimage really portable I hade to bundle them with their own "proot-x86_64" binary file in AppDir/.junest/usr/bin (this is the structure of the Appimage based on Arch Linux).

Now, the ArchImages are AppImages that "think" to run in PROOT mode, but they are into an environment that works with namespaces.

My system have not PROOT installed, but I have "bubblewrab" by default.

@kenderipa , from the list you gave me in the previous issue, I have seen that on your system you have not "bubblewrap" installed. It is higly used to run third party programs "isolated" (also Flatpak depends on it).

@shlozm Have you got bubblewrap installed on your system?

If not, what happens if you two install it and try to run the AppImage using an alias?

May be this an issue with namespaces then?

Let me know.

EDIT: https://en.wikipedia.org/wiki/Linux_namespaces

In fact, as @shlozm said, to made the AppImage run normally, it have to use a different alias, not "gimp", and Namespaces are ment to use different processes in parallel.

The AppRun into the AppImage is calling the internal /·junest/usr/bin/gimp binary, so tthe process "gimp" is called for the first time, having "gimp" called twice made the app not work.

Bubblewrap is made to solve this process and made them work in parallel.

It should be packaged for all the GNU/Linux distribution (being Flatpak available for all them).

EDIT2: about the Virtual Machine I used to create the same desktopt of @kenderipa, Virtualbox needs hardware vitualization enabled on the host. Namespaces of the kernel were used from bubblewrap installed on the host, so my Appimages were working on the VM, this is why I was unable to reproduce the issue.

@shlozm
Copy link
Author

shlozm commented Dec 24, 2023

I did not have bubblewrap installed, unfortunately even after installing bubblewrap the problem persists. I even rebooted. Is there any environment variable that needs to be set?

I attached a copy of my bashrc and profile, also a list of all installed packages.
I am running a minimal Debian 12 install with xorg and the qtile wm in a virtual environment (vmware)

Thank you so much for all the time and effort!

bashrc.txt
installed.txt
profile.txt

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 24, 2023

@shlozm

you have not export PATH=$PATH:$(xdg-user-dir USER)/.local/bin in the ~/.bashrc

EDIT: now AppMan can test if that line is in ~/.bashrc, if not, it will add it at first start 0ad8615

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

@shlozm

you have not export PATH=$PATH:$(xdg-user-dir USER)/.local/bin in the ~/.bashrc

EDIT: now AppMan can test if that line is in ~/.bashrc, if not, it will add it at first start 0ad8615

It is in my $PATH because it gets set in .profile
echo $PATH
/home/sz/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

but I will add it to .bashrc and see if it helps

update: it did not help and now it's in my $PATH twice!
echo $PATH
/home/sz/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/sz/.local/bin:/home/sz/.local/bin

Maybe appman should check .profile as well, or maybe it makes no difference if it's there twice?

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 25, 2023

ivan@debian:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/ivan/.local/bin

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

ivan@debian:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/ivan/.local/bin

Does the order matter? I'll test it

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

ivan@debian:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/ivan/.local/bin

That worked!!!
I edited my .profile so that instead of PATH="$HOME/.local/bin:$PATH" it has PATH="$PATH:$HOME/.local/bin"

and now
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/sz/.local/bin

and ... it works!

Thank you!

But please note: that when
echo $PATH
/home/sz/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/sz/.local/bin:/home/sz/.local/bin
it did not work. So that for a Debian system appman should check .profile and edit it there, you can see my original .profile in the file I attached before.
My original .profile is what Debian automatically installs besides the last 3 lines...

Update: I removed bubblewrap just to test and it still works

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 25, 2023

My original .profile is what Debian automatically installs besides the last 3 lines...

mine too (on the left)

Istantanea_2023-12-25_01-47-07

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

I see. Then I don't understand why adding export PATH=$PATH:$(xdg-user-dir USER)/.local/bin to my .bashrc resulted in a different order of $PATH then yours. The result by me was having .local/bin in my $PATH at the beginning and at the end (twice!). By editing .profile and removing the line from .bashrc my $PATH is now like yours, AND everything works! Very strange that the order makes a difference but it seems that it does.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 25, 2023

I'd like to keep the default .profile file as is and investigate on why our output is different.

I'm looking around on the forums and seems that more of this is related to the login shell.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 25, 2023

The line 60 of my .bashrc is diferent (I'm on the left):

Istantanea_2023-12-25_02-06-19

and you have additional lines:

Istantanea_2023-12-25_02-07-21

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

I just tested it again, I changed .profile back to default, added export PATH=$PATH:$(xdg-user-dir USER)/.local/bin to my .bashrc, and rebooted, now:
echo $PATH
/home/sz/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/sz/.local/bin:/home/sz/.local/bin
AND gimp won't run anymore!

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 25, 2023

About PS1 https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html

May be this change related to the WM you have installed?

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

About PS1 https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html

May be this change related to the WM you have installed?

No just personal preference, and the rest are just some extra aliases, I doubt any of that makes a difference, if you want I can test.

Update I commented all those lines out and I placed the export PATH=$PATH:$(xdg-user-dir USER)/.local/bin line at the end exactly as you have it, but it made no difference
sz@debqtl:~$ echo $PATH
/home/sz/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/sz/.local/bin:/home/sz/.local/bin

AND gimp won't run

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 25, 2023

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 25, 2023

I'm tempted to edit the new function in AppMan from:

if $(! grep -q 'export PATH=$PATH:$(xdg-user-dir USER)/.local/bin' $HOME/.bashrc); then
	echo -e '\nexport PATH=$PATH:$(xdg-user-dir USER)/.local/bin\n' >> $HOME/.bashrc
fi

to

if $(! grep -q 'export PATH=$PATH:$(xdg-user-dir USER)/.local/bin' $HOME/.bashrc); then
	echo -e '\nexport PATH=$PATH:$(xdg-user-dir USER)/.local/bin\nPATH=$PATH\n' >> $HOME/.bashrc
fi

but first I'd like to know the reason because our output is different.

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

According to this https://stackoverflow.com/questions/13830594/when-i-execute-bash-the-path-keeps-repeating-itself
the proper place to set $PATH is .profile, if set in .bashrc also $PATH repeats itself and will only use first instance, I tested this on Arch linux as well, when I set the $PATH in .bashrc it repeats itself and that's even without $PATH being set in .profile, probably once when I log in and again when I open my terminal emulator.
Regardless, in Debian where the $PATH gets set in .profile by default AND you wish to change the order, it would seem that the proper way would be to set it in .profile or to edit the $PATH some other way to ensure that .local/bin is only at the end.

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

According to this: https://superuser.com/questions/1716235/debian-linux-path-variable-repeats-path
Debian purposely put $HOME/.local/bin first in the $PATH so that a user's custom binaries should run instead of a global binary with the same name, because the $PATH is always searched in order. Which is what is happening with the Archimages when $HOME/.local/bin is first as Debian sets it by default. Changing the order would cause other binaries the user has with the same name as global binaries (i.e. if the user has a custom script for ls) not to run. Something to consider. It doesn't affect me but it may affect others.

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

I'm tempted to edit the new function in AppMan from:

if $(! grep -q 'export PATH=$PATH:$(xdg-user-dir USER)/.local/bin' $HOME/.bashrc); then
	echo -e '\nexport PATH=$PATH:$(xdg-user-dir USER)/.local/bin\n' >> $HOME/.bashrc
fi

to

if $(! grep -q 'export PATH=$PATH:$(xdg-user-dir USER)/.local/bin' $HOME/.bashrc); then
	echo -e '\nexport PATH=$PATH:$(xdg-user-dir USER)/.local/bin\nPATH=$PATH\n' >> $HOME/.bashrc
fi

but first I'd like to know the reason because our output is different.

when I tried the proposed edit (with the default Debian .profile) this is the result:
echo $PATH
/home/sz/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/sz/.local/bin:/home/sz/.local/bin

As you can see .local/bin is still first, and .local/bin is at the end twice. And, of course gimp won't run.

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

Do you have a .bash_profile or .bash_login in your home directory? On top of .profile it says:

~/.profile: executed by the command interpreter for login shells.
This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
exists.

I don't, but if you do that could be the reason for the difference.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 25, 2023

Do you have a .bash_profile or .bash_login in your home directory? On top of .profile it says:

~/.profile: executed by the command interpreter for login shells.
This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
exists.

I don't, but if you do that could be the reason for the difference.

Nope, I have not them.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 25, 2023

I wont to use sed or similar commands to edit the correct order, nor I'd like to edit ~/.profile using sed, AppMan may seem to be too much "editor" on the defaults and may give problems.

@ivan-hc
Copy link
Owner

ivan-hc commented Dec 25, 2023

This should be the solution for all our evils

if [ $AMCLI == appman ] 2>/dev/null; then
	if $(! grep -q 'export PATH=$PATH:$(xdg-user-dir USER)/.local/bin' $HOME/.bashrc); then
		echo 'export PATH=$(echo $PATH | tr ":" "\n" | grep -v "/.local/bin" | tr "\n" ":" | sed ''s/.$//'')' >> $HOME/.bashrc
		echo -e 'export PATH=$PATH:$(xdg-user-dir USER)/.local/bin\n' >> $HOME/.bashrc
	fi
fi

what do you think about it?

@shlozm
Copy link
Author

shlozm commented Dec 25, 2023

This should be the solution for all our evils

if [ $AMCLI == appman ] 2>/dev/null; then
	if $(! grep -q 'export PATH=$PATH:$(xdg-user-dir USER)/.local/bin' $HOME/.bashrc); then
		echo 'export PATH=$(echo $PATH | tr ":" "\n" | grep -v "/.local/bin" | tr "\n" ":" | sed ''s/.$//'')' >> $HOME/.bashrc
		echo -e 'export PATH=$PATH:$(xdg-user-dir USER)/.local/bin\n' >> $HOME/.bashrc
	fi
fi

what do you think about it?

Worked perfectly!
With Debian .profile at default and my $PATH
echo $PATH
/home/sz/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

I ran

if $(! grep -q 'export PATH=$PATH:$(xdg-user-dir USER)/.local/bin' $HOME/.bashrc); then
echo 'export PATH=$(echo $PATH | tr ":" "\n" | grep -v "/.local/bin" | tr "\n" ":" | sed ''s/.$//'')' >> $HOME/.bashrc
echo -e 'export PATH=$PATH:$(xdg-user-dir USER)/.local/bin\n' >> $HOME/.bashrc
fi

And now my $PATH
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/sz/.local/bin

Thank you very much!

ivan-hc added a commit to ivan-hc/AM that referenced this issue Dec 25, 2023
Some systems make local binaries appear as the first selection, giving ~/.local/bin less priority than other $PATHs.

With this AppMan modification, the `echo $PATH` command will give the following output:

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/USER/.local/bin

With this order, symlinks and executables in ~/.local/bin will have due priority, especially in minimal systems.
ivan-hc added a commit to ivan-hc/AM that referenced this issue Dec 26, 2023
Changed the "_patch_bashrc_and_profile" function to only modify the ~/.profile file if the output of `echo $PATH` places $HOME/.local/bin first in the $PATH list.

Only systems that need it will be affected by this patch, while all systems will only have two lines added to the bottom of the ~/.bashrc file.

See the previous commits listed at ivan-hc/AppMan#25 and ivan-hc/AppMan#26
ivan-hc added a commit that referenced this issue Dec 26, 2023
Changed the "_patch_bashrc_and_profile" function to only modify the ~/.profile file if the output of `echo $PATH` places $HOME/.local/bin first in the $PATH list.

Only systems that need it will be affected by this patch, while all systems will only have two lines added to the bottom of the ~/.bashrc file.

See the previous commits listed at #25 and #26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants