[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How To Permanently Add-to a Users PATH Statement in the Bash Shell



* On 2020 07 Jul 08:58 -0500, Stephen P. Molnar wrote:
> The Subject line is the problem with my Debian Buster platform. Now from
> Google I see that there has been a change in the way Debian handles this
> problem.
> 
> My user path statement is:
> 
> comp@AbNormal:~$ echo $PATH
> /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
> 
> Now I have a number of applications that have multiple executable in the app
> /bin subdirectory. Hence the need to add to the users PATH statement
> 
> As an example I have:
> 
> /home/comp/Apps/ADFRsuite-1.0/bin
> 
> which I would like to add to the PATH statement and:
> 
> export PATH=$PATH:'/home/comp/Apps/ADFRsuite-1.0/bin'
> 
> This works unless I open a new Terminal, in which case it is no longer in
> the PATH.
> 
> How do I make the addition persistent?

I just saw a related blog post from the Debian Planet blog aggregator
(https://planet.debian.org/):

https://noah.meyerhans.us/2020/07/07/setting-environment-variables-for-gnome-session/

The post does not reference this thread but may have been inspired by it
or not.  Regardless, the author is trying to solve a similar problem
with Gnome on Wayland.

As I read it, where an environment variable should be set depends on the
intended scope of the variable.  One comment in response to the blog
post states that ~/.profile should be used to set such variables and
that even Gnome on Wayland will read this file (I've not tried it yet
myself).

There is a caveat!  Isn't there always?  The comments at the top of
/etc/skel/.profile note:

# ~/.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.

For whatever historical reason I do have ~/.bash_profile which does
nothing other than source ~/.bashrc when Bash is invoked as a login
shell.  I think I'll move it out of the way and use ~/.profile instead.

Okay, having tried that I see that it works!  Set a variable in
~/.profile, restart the Gnome session (I did a warm restart and cold
boot) and using the "Run Command" dialog (Alt-F2 in Gnome) run:

	'sh -c "env > /tmp/env"

and then see if your custom variable is set.  In my case with the laptop
running Bullseye it does work.  I now see several things that I dumped
in ~/.bashrc that aren't Bash specific and would be better put in
~/.profile.  Good thread.

- Nate

-- 

"The optimist proclaims that we live in the best of all
possible worlds.  The pessimist fears this is true."

Web: https://www.n0nb.us
Projects: https://github.com/N0NB
GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819

Attachment: signature.asc
Description: PGP signature


Reply to: