Catalina’s zsh and its .zshrc file

bashterminalzsh

I am trying hard to wrap my head around zsh "upgrade" from bash in macOS Catalina. Most of the things are great, actually. However, I cannot figure out why I am experiencing difficulties, like accessing Anaconda rather than built in Python despite the fact that I put the path to it:

# Anaconda3 2019.10
export PATH="/Library/Frameworks/Python.framework/anaconda3/bin:$PATH"

But if I have this too, under Anaconda's path, then the system does not "see" Anaconda anymore (I've commented it out, for now):

# Local path:
# export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:$PATH"

Also, I have some odd line added to gcc (again, I commented out the odd line):

# Setting gcc compiler
export PATH="/usr/local/gcc-9.2/bin:$PATH"
# export CC="/usr/local/gcc-9.2/bin"

With lines commented out things are working now. But can anyone explain what is wrong in them and what, specifically, export CC should to on top of the export PATH line?

Thanks!

Best Answer

Since the variable setting you want to achieve are both to be run once only per session and not for every subshell, you have to place their initialisation definition within .zprofile and not within .zshrc.

Here are the fixed version of your settings which should work:

# Anaconda3 2019.10
export PATH="/Library/Frameworks/Python.framework/anaconda3/bin:${PATH}:/usr/local/bin"

Here my explanation is I bet you have 2 versions of anaconda the older one being located within /usr/local/bin.

# Setting gcc compiler
export PATH="/usr/local/gcc-9.2/bin:${PATH}"
export CC="/usr/local/gcc-9.2/bin/gcc"

Here my explanation is that the CC variable should contain not the PATH where to find gcc but the exact pathname of the compiler.

If you want to check the correctness of your modifications, don't exit your session. Just enter in any terminal:

. ~/.zprofile