Discussion:
cannot customize terminal PATH anywhere
Florin Andrei
2018-08-22 19:04:14 UTC
Permalink
Running XFCE 4.12 on Ubuntu 16.04 in vncserver. The PATH variable in any
terminal is very short:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

I've tried overriding it everywhere:
- the various *profile files in /etc, home and so on
- /etc/environment
- various *xinit* files in home and /etc

Nothing seems to work. XFCE seems super-strict in overriding that
variable. I can get it to work just fine in a text-mode ssh session to
that system, but in a terminal running within XFCE the PATH variable is
overriden every time.

I'm mystified as to why this is, and how can I fix it.
--
Florin Andrei
http://florin.myip.org/
Igor Zakharov
2018-08-22 19:08:18 UTC
Permalink
Post by Florin Andrei
Running XFCE 4.12 on Ubuntu 16.04 in vncserver. The PATH variable in any
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- the various *profile files in /etc, home and so on
- /etc/environment
- various *xinit* files in home and /etc
Nothing seems to work. XFCE seems super-strict in overriding that
variable. I can get it to work just fine in a text-mode ssh session to
that system, but in a terminal running within XFCE the PATH variable is
overriden every time.
I'm mystified as to why this is, and how can I fix it.
Hi,

Have you tried ~/.bashrc? I believe this is what Ubuntu normally uses for that purpose.

Regards,
Igor
Chris Green
2018-08-22 20:46:38 UTC
Permalink
Post by Igor Zakharov
Post by Florin Andrei
Running XFCE 4.12 on Ubuntu 16.04 in vncserver. The PATH variable in any
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- the various *profile files in /etc, home and so on
- /etc/environment
- various *xinit* files in home and /etc
Nothing seems to work. XFCE seems super-strict in overriding that
variable. I can get it to work just fine in a text-mode ssh session to
that system, but in a terminal running within XFCE the PATH variable is
overriden every time.
I'm mystified as to why this is, and how can I fix it.
Hi,
Have you tried ~/.bashrc? I believe this is what Ubuntu normally uses for that purpose.
The 'right' place to add things to the PATH variable is generally
.profile, but for bash this may be overridden by .bash_profile and
.bash_login.

If you add to the path in .bashrc then the addition may get added more
than once, not a serious problem but is a bit 'messy'.

So, if either .bash_profile or .bash_login exists then .profile will
be ignored by bash at login. Remember also that .profile (or the
others) are only sourced at login, whereas .bashrc is sourced every
time bash is started.
--
Chris Green
MR ZenWiz
2018-08-22 21:41:09 UTC
Permalink
Post by Chris Green
If you add to the path in .bashrc then the addition may get added more
than once, not a serious problem but is a bit 'messy'.
There are numerous ways to clean up any list and purge the duplicates
while preserving the order of the unique entries. The PATH is just a
colon-separated list of path strings.

It is also easy enough to check the PATH to see if it already contains
the path you want to add and skip that one.

HTH.
MR
Chris Green
2018-08-23 11:07:18 UTC
Permalink
Post by MR ZenWiz
Post by Chris Green
If you add to the path in .bashrc then the addition may get added more
than once, not a serious problem but is a bit 'messy'.
There are numerous ways to clean up any list and purge the duplicates
while preserving the order of the unique entries. The PATH is just a
colon-separated list of path strings.
Quite true, but why make things difficult for yourself, adding to PATH
in .profile (or .bash_profile, or .bash_login) works in just about
every normal setup and adds what you want just once.
Post by MR ZenWiz
It is also easy enough to check the PATH to see if it already contains
the path you want to add and skip that one.
Yes, but do you really want to check it every time, computers are good
at automating things you know! :-)
--
Chris Green
MR ZenWiz
2018-08-24 04:48:07 UTC
Permalink
Post by Chris Green
Quite true, but why make things difficult for yourself, adding to PATH
in .profile (or .bash_profile, or .bash_login) works in just about
every normal setup and adds what you want just once.
Except that bash also always reads .bashrc, whereas .profile is
typically only read when you open an interactive session.

Hence .bashrc is the correct and most effective place to make changes
for all your bash instances.
Post by Chris Green
Post by MR ZenWiz
It is also easy enough to check the PATH to see if it already contains
the path you want to add and skip that one.
Yes, but do you really want to check it every time, computers are good
at automating things you know! :-)
Which is why you put the checks into your .bashrc. That's what checks
it every time for me. Why would you not want to do that and automate
the handling?

For the record, .profile is for all Bourne and Bourne-related shells,
including bash interactive sessions. .bashrc is for all bash
sessions, interactive or command line (or program system() calls).

I do what works. It beats complaining about it, and I get what I want.

Cheers.

MR
Chris Green
2018-08-24 10:22:09 UTC
Permalink
Post by MR ZenWiz
Post by Chris Green
Quite true, but why make things difficult for yourself, adding to PATH
in .profile (or .bash_profile, or .bash_login) works in just about
every normal setup and adds what you want just once.
Except that bash also always reads .bashrc, whereas .profile is
typically only read when you open an interactive session.
Hence .bashrc is the correct and most effective place to make changes
for all your bash instances.
No, if you want something done *once*, like adding something to PATH
then .profile is the right place. PATH is exported so *all*
subsequent bash instances will get the chnaged PATH.
--
Chris Green
houghi
2018-08-24 10:31:49 UTC
Permalink
Post by Chris Green
No, if you want something done *once*, like adding something to PATH
then .profile is the right place. PATH is exported so *all*
subsequent bash instances will get the chnaged PATH.
Can we at least agree that this is a bash issue and not an XFCE issue
and should not be here on the list?

houghi
Chris Green
2018-08-24 10:42:03 UTC
Permalink
Post by Chris Green
No, if you want something done *once*, like adding something to PATH
then .profile is the right place. PATH is exported so *all*
subsequent bash instances will get the chnaged PATH.
Can we at least agree that this is a bash issue and not an XFCE issue and
should not be here on the list?
You're basically right, though the OP was claiming thst XFCE 'removed'
a lot of the default settings from /etc/bash.bashrc and /etc/profile.
--
Chris Green
houghi
2018-08-24 15:16:58 UTC
Permalink
Post by Chris Green
Post by Chris Green
No, if you want something done *once*, like adding something to PATH
then .profile is the right place. PATH is exported so *all*
subsequent bash instances will get the chnaged PATH.
Can we at least agree that this is a bash issue and not an XFCE issue and
should not be here on the list?
You're basically right, though the OP was claiming thst XFCE 'removed'
a lot of the default settings from /etc/bash.bashrc and /etc/profile.
I know. It doesn't. OP was misstaken.

Florin Andrei
2018-08-22 22:38:21 UTC
Permalink
Ok, ~/.bashrc is the only place that allowed me to change $PATH. It's
not ideal, but at least I have something to work with.

It's still not clear to me why XFCE is so strict with nuking all
system-level alterations to the environment variables, and replacing it
with its own value.
--
Florin Andrei
http://florin.myip.org/
Chris Green
2018-08-23 11:09:08 UTC
Permalink
Ok, ~/.bashrc is the only place that allowed me to change $PATH. It's not
ideal, but at least I have something to work with.
It's still not clear to me why XFCE is so strict with nuking all
system-level alterations to the environment variables, and replacing it with
its own value.
Unless you have changed something XFCE doesn't do anyhting to change
from a 'standard' Debian/Ubuntu setup.
--
Chris Green
Loading...