zsh-users
 help / color / mirror / code / Atom feed
* root's path
@ 2012-03-17  1:45 sergio
  2012-03-17  4:44 ` Benjamin R. Haskell
       [not found] ` <alpine.LNX.2.01.1203170040230.18133__19065.733991056$1331959656$gmane$org@hp.internal>
  0 siblings, 2 replies; 9+ messages in thread
From: sergio @ 2012-03-17  1:45 UTC (permalink / raw)
  To: zsh-users

Hello.

How zsh sets root's $path (and $PATH)?
bash uses /etc/profile, for sudo completion there are /etc/zsh/zshrc and
$PATH for non root is in /etc/zsh/zshenv. But I can't find root path
anywhere.

I have one machine on which path for root not changed:
% =sudo ifconfig
sudo: ifconfig: command not found
% =sudo -s
# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
#

What should I check?

-- 
sergio.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: root's path
  2012-03-17  1:45 root's path sergio
@ 2012-03-17  4:44 ` Benjamin R. Haskell
  2012-03-17  8:58   ` sergio
       [not found] ` <alpine.LNX.2.01.1203170040230.18133__19065.733991056$1331959656$gmane$org@hp.internal>
  1 sibling, 1 reply; 9+ messages in thread
From: Benjamin R. Haskell @ 2012-03-17  4:44 UTC (permalink / raw)
  To: sergio; +Cc: zsh-users

On Sat, 17 Mar 2012, sergio wrote:

> Hello.
>
> How zsh sets root's $path (and $PATH)?
> bash uses /etc/profile, for sudo completion there are /etc/zsh/zshrc 
> and $PATH for non root is in /etc/zsh/zshenv. But I can't find root 
> path anywhere.

Zsh often ends up using /etc/profile or the equivalent.  On Gentoo, 
for example, /etc/zsh/zprofile sources /etc/profile.env.  On OpenSUSE, 
/etc/zprofile sources /etc/profile.


> I have one machine on which path for root not changed:
> % =sudo ifconfig
> sudo: ifconfig: command not found
> % =sudo -s
> # echo $PATH
> /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
> #
>
> What should I check?

No good ideas, other than /etc/zsh/zprofile or /etc/zprofile (whatever 
systemwide profile file your Zsh was compiled to search for).

What distribution is it?

-- 
Best,
Ben


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: root's path
  2012-03-17  4:44 ` Benjamin R. Haskell
@ 2012-03-17  8:58   ` sergio
  0 siblings, 0 replies; 9+ messages in thread
From: sergio @ 2012-03-17  8:58 UTC (permalink / raw)
  To: zsh-users

On 03/17/2012 08:44 AM, Benjamin R. Haskell wrote:

> Zsh often ends up using /etc/profile or the equivalent.  On Gentoo, 
> for example, /etc/zsh/zprofile sources /etc/profile.env.  On OpenSUSE, 
> /etc/zprofile sources /etc/profile.

On good and bad sysmtes:
/etc/zsh/zprofile is commented out
/etc/zprofile doens't exists

> What distribution is it?
debian


> If you are on a Linux system then check /etc/environment. It is part
> of pam_env.so.  You can read about it with "man 7 pam"
Robert, please reply next time to the list.

/etc/environment is empty


-- 
sergio.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: root's path
       [not found] ` <alpine.LNX.2.01.1203170040230.18133__19065.733991056$1331959656$gmane$org@hp.internal>
@ 2012-03-17 11:13   ` Christian Neukirchen
  2012-03-17 11:21     ` Mikael Magnusson
  0 siblings, 1 reply; 9+ messages in thread
From: Christian Neukirchen @ 2012-03-17 11:13 UTC (permalink / raw)
  To: zsh-users

"Benjamin R. Haskell" <zsh@benizi.com> writes:

> On Sat, 17 Mar 2012, sergio wrote:
>
>> Hello.
>>
>> How zsh sets root's $path (and $PATH)?
>> bash uses /etc/profile, for sudo completion there are /etc/zsh/zshrc
>> and $PATH for non root is in /etc/zsh/zshenv. But I can't find root
>> path anywhere.
>
> Zsh often ends up using /etc/profile or the equivalent.  On Gentoo,
> for example, /etc/zsh/zprofile sources /etc/profile.env.  On OpenSUSE,
> /etc/zprofile sources /etc/profile.

Shouldn't $PATH be set in /etc/zshenv rather than zprofile?
Else, it's impossible to override $PATH in ~/.zshenv.

-- 
Christian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: root's path
  2012-03-17 11:13   ` Christian Neukirchen
@ 2012-03-17 11:21     ` Mikael Magnusson
  2012-03-17 14:52       ` TJ Luoma
  2012-03-17 15:33       ` Bart Schaefer
  0 siblings, 2 replies; 9+ messages in thread
From: Mikael Magnusson @ 2012-03-17 11:21 UTC (permalink / raw)
  To: Christian Neukirchen; +Cc: zsh-users

On 17 March 2012 12:13, Christian Neukirchen <chneukirchen@gmail.com> wrote:
> "Benjamin R. Haskell" <zsh@benizi.com> writes:
>
>> On Sat, 17 Mar 2012, sergio wrote:
>>
>>> Hello.
>>>
>>> How zsh sets root's $path (and $PATH)?
>>> bash uses /etc/profile, for sudo completion there are /etc/zsh/zshrc
>>> and $PATH for non root is in /etc/zsh/zshenv. But I can't find root
>>> path anywhere.
>>
>> Zsh often ends up using /etc/profile or the equivalent.  On Gentoo,
>> for example, /etc/zsh/zprofile sources /etc/profile.env.  On OpenSUSE,
>> /etc/zprofile sources /etc/profile.
>
> Shouldn't $PATH be set in /etc/zshenv rather than zprofile?
> Else, it's impossible to override $PATH in ~/.zshenv.

Absolutely not, if you set PATH from *env, it makes it impossible to
inherit the PATH from the parent process' environment, even in
scripts, which will break a lot of things. The path should only be set
once on login of the current session, ie in zprofile if zsh is your
login shell, otherwise in the startup file for your login shell.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: root's path
  2012-03-17 11:21     ` Mikael Magnusson
@ 2012-03-17 14:52       ` TJ Luoma
  2012-03-17 14:54         ` Mikael Magnusson
  2012-03-17 15:33       ` Bart Schaefer
  1 sibling, 1 reply; 9+ messages in thread
From: TJ Luoma @ 2012-03-17 14:52 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Christian Neukirchen, zsh-users

On Mar 17, 2012, at 7:22 AM, Mikael Magnusson <mikachu@gmail.com> wrote:

> Absolutely not, if you set PATH from *env, it makes it impossible to
> inherit the PATH from the parent process' environment, even in
> scripts, which will break a lot of things. The path should only be set
> once on login of the current session, ie in zprofile if zsh is your
> login shell, otherwise in the startup file for your login shell.

Fwiw, Zsh on the Mac inits its path from /etc/zshenv

The global environmental variable has to be set _somewhere_ otherwise
there's nothing for shells to inherit.

TjL


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: root's path
  2012-03-17 14:52       ` TJ Luoma
@ 2012-03-17 14:54         ` Mikael Magnusson
  2012-03-17 15:02           ` Mikael Magnusson
  0 siblings, 1 reply; 9+ messages in thread
From: Mikael Magnusson @ 2012-03-17 14:54 UTC (permalink / raw)
  To: TJ Luoma; +Cc: Christian Neukirchen, zsh-users

On 17 March 2012 15:52, TJ Luoma <tj@luo.ma> wrote:
> On Mar 17, 2012, at 7:22 AM, Mikael Magnusson <mikachu@gmail.com> wrote:
>
>> Absolutely not, if you set PATH from *env, it makes it impossible to
>> inherit the PATH from the parent process' environment, even in
>> scripts, which will break a lot of things. The path should only be set
>> once on login of the current session, ie in zprofile if zsh is your
>> login shell, otherwise in the startup file for your login shell.
>
> Fwiw, Zsh on the Mac inits its path from /etc/zshenv

I know, that's a bug in osx.

> The global environmental variable has to be set _somewhere_ otherwise
> there's nothing for shells to inherit.

Like I said, the correct place to set it is in the profile file for
the login shell.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: root's path
  2012-03-17 14:54         ` Mikael Magnusson
@ 2012-03-17 15:02           ` Mikael Magnusson
  0 siblings, 0 replies; 9+ messages in thread
From: Mikael Magnusson @ 2012-03-17 15:02 UTC (permalink / raw)
  To: TJ Luoma; +Cc: Christian Neukirchen, zsh-users

On 17 March 2012 15:54, Mikael Magnusson <mikachu@gmail.com> wrote:
> On 17 March 2012 15:52, TJ Luoma <tj@luo.ma> wrote:
>> Fwiw, Zsh on the Mac inits its path from /etc/zshenv
>
> I know, that's a bug in osx.
>
>> The global environmental variable has to be set _somewhere_ otherwise
>> there's nothing for shells to inherit.
>
> Like I said, the correct place to set it is in the profile file for
> the login shell.

Side note, they do set the path in the correct file when bash is the
login shell, ie /etc/profile.

18:47 <necromancer> when i load zsh as my shell in mac os x, i noticed
it takes a bit longer than bash to run login and show my prompt
18:48 <Mikachu> osx does at least one stupid thing in the global rc,
maybe they do other stupid things too
18:53 <et> necromancer: comment out the path_helper thing in
/etc/zshenv and set the paths yourself
18:53 <necromancer> thanks
18:55 <Mikachu> that's the stupid thing i know about, is it also slow?
18:57 <necromancer> MUCH faster now that i removed that..
18:57 <necromancer> thanks et
18:58 <Mikachu> two birds in one stone
19:00 <et> Mikachu: it scans directories and files, and if the
accesses aren't cached, it's quite slow

16:02 <Mikachu> luuse: do you have a /etc/zprofile?
16:03 <luuse> no
16:03 <Mikachu> and /etc/profile contains a call to path_helper?
16:05 <luuse> yes


-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: root's path
  2012-03-17 11:21     ` Mikael Magnusson
  2012-03-17 14:52       ` TJ Luoma
@ 2012-03-17 15:33       ` Bart Schaefer
  1 sibling, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2012-03-17 15:33 UTC (permalink / raw)
  To: zsh-users

On Mar 17, 12:21pm, Mikael Magnusson wrote:
}
} > Shouldn't $PATH be set in /etc/zshenv rather than zprofile?
} > Else, it's impossible to override $PATH in ~/.zshenv.
} 
} Absolutely not, if you set PATH from *env, it makes it impossible to
} inherit the PATH from the parent process' environment, even in
} scripts, which will break a lot of things.

I'd go further and say that except in carefully considered circumstances,
the /etc/zshenv file should always be empty or not exist.  If it does set
the path, it should only append to it, not prepend or clobber (again,
except in certain circumstances).

} The path should only be set once on login of the current session, ie
} in zprofile if zsh is your login shell, otherwise in the startup file
} for your login shell.

This is ideal but practically speaking has become unworkable in recent
years.  The use of remote terminals and window systems has resulted in
an unpredictable variety of configurations such that there is no way to
guarantee that any particular interactive shell is a login shell or was
started from a login shell environment; i.e., "current session" is now
pretty much meaningless in the process environment sense.

In fact the OP's most likely problem is that on the "good system" he
has a login shell (or there is one somewhere nearer the root of his
process tree), but on the "bad system" he has only an interactive shell.

So it's often necessary to adjust the path in /etc/zshrc to make sure it
is sane for all interactive shells.  Or, after careful consideration, to
do so in /etc/zshenv if the path for NON-interactive shells is incomplete.

-- 
Barton E. Schaefer


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-03-17 15:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-17  1:45 root's path sergio
2012-03-17  4:44 ` Benjamin R. Haskell
2012-03-17  8:58   ` sergio
     [not found] ` <alpine.LNX.2.01.1203170040230.18133__19065.733991056$1331959656$gmane$org@hp.internal>
2012-03-17 11:13   ` Christian Neukirchen
2012-03-17 11:21     ` Mikael Magnusson
2012-03-17 14:52       ` TJ Luoma
2012-03-17 14:54         ` Mikael Magnusson
2012-03-17 15:02           ` Mikael Magnusson
2012-03-17 15:33       ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).