Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How does variable PATH get updated by Debian instructions or other commands? (and related questions)

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
IagoGV
Posts: 10
Joined: 2021-09-23 08:46

How does variable PATH get updated by Debian instructions or other commands? (and related questions)

#1 Post by IagoGV »

Let me first expose my problem.

A couple of weeks ago I could run jupyter notebook without problems, but today I got the usual jupyter: command not found. I was getting crazy until I realized that the problem was that $HOME/.local/bin was not in variable PATH. In these last weeks I didn't modify explicitely the ~/.bashrc or the ~/.profile files, or the PATH variable. In fact, when I modify it, is by means of export PATH=new_path:$PATH Therefore, I believe that $HOME/.local/bin was in the variable PATH a couple of weeks ago, when I could run jupyter, but some command or Debian/Linux behaviour removed it.

What I did these last weeks is just install new packages by means of apt-get, the usual apt-get upgrade. I also updated rust by means of rustup update. I suspected this might casue the issue because the most new address in PATH by the left was $HOME/cargo/bin.

But now I see that:
  • If I run source ~/.profile, $HOME/.local/bin is attached to PATH, since a part of the .profile file is

    Code: Select all

    if [ -d "$HOME/.local/bin" ] ; then
        PATH="$HOME/.local/bin:$PATH"
    fi
    
  • When I exit the terminal and I open again, the PATH variable is again the default, not including $HOME/.local/bin
So:
  • Why happens this and what can I do so that I do not have to run source ~/.profile each time I open the terminal? (let me add that I do have neither a .bash_profile file nor a .bash_login file as would avoid the use of .profile by
    bash first reads /etc/profile to get values that are defined for all users. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first of these files that exists and is readable.
    https://wiki.debian.org/EnvironmentVariables)
  • Could some other Debian behaviour return the PATH variable to its default?
  • Is there some log file where I can see changes in PATH variable? (I would like to know what was the variable some weeks ago, when jupyter notebook worked without problems.)
Thank you in advance!

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: How does variable PATH get updated by Debian instructions or other commands? (and related questions)

#2 Post by bw123 »

There have been several threads about this the last couple years here on the forum and also on mailing list https://lists.debian.org/debian-user/

When I was using a display manager, I moved the snippet setting users /bin from ~/.profile to the beginning of ~/.bashrc but I'm sure there are different ways to get it done. See for instance https://html.duckduckgo.com/html/?q=lig ... g+bin+path for an explanation.

My ~/.profile does not add $HOME/.local/bin to path it prepends $HOME/bin

Code: Select all

$ cat ~/.profile | grep -A2 PATH
$ cat /etc/os-release
$ bash --version
$ apt policy
Good Luck
resigned by AI ChatGPT

IagoGV
Posts: 10
Joined: 2021-09-23 08:46

Re: How does variable PATH get updated by Debian instructions or other commands? (and related questions)

#3 Post by IagoGV »

Thank you @bw123. Indeed, as in the duckduckgo you linked, I also use lightdm. For the moment, following some idea I read on the web (https://stackoverflow.com/a/57257849/997979 and again https://wiki.debian.org/EnvironmentVariables), I created a file ~/.xsessionrc containing

Code: Select all

if [ -f ~/.profile ]; then
     . ~/.profile
 fi
and it seems it is working.

Post Reply