Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PATH variable in .zshenv or .zshrc

Tags:

path

zsh

My setup is zsh 5.0.5 in arch linux

I have set the PATH variable as below in .zshenv

typeset -U path
path=(~/bin $path)
DW=$HOME/Downloads

but it didn't work. print $PATH shows only

/usr/local/bin:/usr/bin:/usr/bin/vendor_perl:/usr/bin/core_perl

.zshenv was read, because I could see DW variable is set. Only PATH variable isn't set. And what I don't understand is, after rename the .zshenv to .zshrc, PATH variable just works as intended.

Need any special treatment setting environment variables in .zshenv?

like image 236
kReoSo Avatar asked Jan 10 '14 07:01

kReoSo


People also ask

Where is PATH variable stored in Linux?

The PATH environment variable is an important security control. It specifies the directories to be searched to find a command. The default systemwide PATH value is specified in the /etc/profile file, and each user normally has a PATH value in the user's $HOME/. profile file.

What is PATH in Zshrc?

PATH is an environment variable where you tell your system to look for executables when you enter a command in the shell. You can inspect the value of the PATH variable by running the following. $ echo $PATH.

Is PATH a shell variable?

PATH is an environmental variable in Linux and other Unix-like operating systems that tells the shell which directories to search for executable files (i.e., ready-to-run programs) in response to commands issued by a user.


1 Answers

I just encountered this problem myself, and the real answer is that Zsh on Arch sources /etc/profile – which overwrites and exports PATHafter having sourced ~/.zshenv.

See: https://wiki.archlinux.org/index.php/Zsh#Configuration_files

like image 191
Adrian Günter Avatar answered Oct 12 '22 06:10

Adrian Günter