Cygwin path pickiness

Tuesday 15 May 2007This is over 17 years old. Be careful.

I use cygwin to get Unix utilities on Windows. It works remarkably well, allowing me to run Gnu makefiles from a Windows command prompt, and so on. Except when it doesn’t work.

After using a makefile successfully for a week or so, I started getting this:

$ make tar
tar -cvf dot.tar --exclude-from=notar.txt .
make: tar: Command not found
make: *** [tar] Error 127

This was both really aggravating and really familiar. I know I had this exact problem at one point with my last laptop. I tried searching Google, but ended up with a lot of frustrating dead-ends: many people asking similar questions, most of which went unanswered, and a few with chicken-waving answers. They just smelled like shots in the dark. One suggested re-installing cygwin, which I tried, but it didn’t help.

Then, waking up this morning, I remembered what the problem was last time: an empty entry in my PATH environment variable. It was one of those times when I wasn’t even trying to remember something, and it popped into my head, this little detail of an admin problem from a year ago. Not just something vague like, “maybe it’s the path?” but the specific answer of “it’s an empty entry on the path.” And when it struck me, I knew it was right.

My PATH looked something like this (though much longer):

$ set path
Path=.;C:\WINDOWS\system32;C:\Program Files\QuickTime\QTSystem\;;c:\cygwin\bin

That double-semicolon is an empty entry in the path, and cygwin doesn’t like it. Because tar is in c:\cygwin\bin, and that directory is in the path after the empty entry, tar is not found. Fixing PATH to not have the empty entry fixes the problem.

Experimenting further, it seems that other kinds of improprieties in the path also get cygwin’s knickers in a twist. For example, enclosing an entry in double quotes, although allowed in Windows, also stops the path search. Having a non-existent directory is fine, though. Go figure.

So, in short: cygwin’s programs can’t find programs to execute if they are on the path after weird entries. You can either fix the weird entries, or move the cygwin directory up the path before the weirdness.

» 4 reactions

Comments

[gravatar]
Ned,

Have you used the MSYS tools? I've found them to be less susceptible to some cygwin problems (not sure about the PATH handling issue you mention here). For example:

http://trentm.com/blog/archives/2005/03/09/cygwin-ntfs-permissions-badness/


http://www.mingw.org/download.shtml

I install "MSYS-1.0.10.exe" and "msysDTK-1.0.1.exe" from that download table.
[gravatar]
I forgot to add that the Mozilla windows build system (heavily reliant on the GNU tools including autoconf and make) recently switch from Cygwin to MSYS. This is a pretty good validation of the MSYS tools: the Moz build is big.
[gravatar]
Cygwin follows the Law of Leaky Abstractions -- it works well except
when it doesn't. I like it a lot except that it can be too heavy at times.

I tend to run almost everything through cygpath, which seems fix a lot
of problems such as these. Like in your problem (shorten a little):

$ cygpath -up ".;C:\WINDOWS\system32;;c:\cygwin\bin"
.:/cygdrive/c/WINDOWS/system32:/usr/bin
[gravatar]
where do i have to change the path variable?

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.