0

I use Cygwin on Windows 7. I'm not really a Windows user, so it's already a little inconvenient for me to have to have this extra layer in between my OS and Zsh, my shell of choice.

Now, I frequently have to change my PATH in Windows. The one you change via the advanced system preferences. However, I've noticed that this PATH change does not propagate to Zsh under Cygwin.

Very well, so I look in .zshrc, and I find:

# User configuration

export PATH="/usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Intel/iCLS Client:/cygdrive/c/Program Files/Intel/iCLS Client:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files (x86)/Intel/OpenCL SDK/3.0/bin/x86:/cygdrive/c/Program Files (x86)/Intel/OpenCL SDK/3.0/bin/x64:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files/ffmpeg/bin"
# export MANPATH="/usr/local/man:$MANPATH"

I did not add that (well, maybe the ffmpeg bit at the end). Where does it come from? Does Cygwin set this up initially when it installs Zsh? Does Oh-my-zsh figure this out somehow? Somehow it must've known my PATH at some point and added that to my .zshrc.

The Cygwin FAQ says,

All Windows environment variables are imported when Cygwin starts

But that does not seem to be the case—or the export PATH declaration in the .zshrc overwrites whatever Cygwin does.

Needless to say, I'm very confused. So here's the question:

When I edit my Windows PATH, what is the recommended way of telling a Cygwin shell that it has changed? Do I need to always edit my shell profile manually? Or can this be auto-generated?

1 Answer 1

2

On the install.sh script for oh-my-zsh you can see this:

echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"
sed -i -e "/export PATH=/ c\\
export PATH=\"$PATH\"
" ~/.zshrc

The PATH you had on your Cygwin shell (which in turn was copied from Windows when you started Cygwin) was added during installation to the .zshrc, effectively locking it.

Cygwin picks up these environment variables on startup, then the .zshrc (and other files such as .zshenv) are run, overriding any environment variables exported.

If you removed the export statement from the .zshrc, Zsh would just pick up the PATH from its parent process, which should be Windows' PATH.

1
  • Thanks. That actually is a very inconvenient behavior, at least in the case of using it with Cygwin.
    – slhck
    Jul 4, 2014 at 12:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .