4

When attempting to clone a repository, one of our computers gives the following error:

[Error 3] The system cannot find the path specified: '%HOMEDRIVE%%HOMEPATH%\\_hgcookies'

If I understand correctly, this directory is supposed to be created and managed by the KilnAuth extension. The directory does not exist on the computer having the problem.

This computer runs Win7 64-bit.

flag

2 Answers

4

This turned out to be a problem with the way Windows 7 expands (or in this case, fails to expand) nested environment variables.

In kilnauth.py, the following line is used to determine the location of the _hgcookies directory which stores the kilnauth data:

cookie_path = os.path.expanduser('~\\_hgcookies')

The Python documentation states that:

On Windows [os.path.expanduser], HOME and USERPROFILE will be used if set, otherwise a combination of HOMEPATH and HOMEDRIVE will be used. An initial ~user is handled by stripping the last directory component from the created user path derived above.

On the problem computer, HOME=%HOMEDRIVE%%HOMEPATH%. In the kilnauth.py line shown above, this should expand out to HOME=C:\Users\<username>, but this did not happen. Instead, the nested environment variables were not expanded. This resulted in an invalid path for _hgcookies.

Once the invalid path is stored, kilnauth.py then runs:

os.mkdir(cookie_path)

which results in the error shown in the problem statement.

It is not clear why the nested environment variables are not expanded properly. However there is a workaround. On the problem computer, we set HOME=C:\Users\<username> directly rather than using %HOMEDRIVE%%HOMEPATH%.

After a reboot, this solved the problem.

NOTE: There are several other places in the Mercurial source code where this same pattern is used to determine the user's home path. So even if kilnauth.py was changed to be more paranoid about finding the home path, there would likely still be other problems.

link|flag
Great answer! Thanks Tim. – Rob Sobers Nov 16 2010 at 15:24
I've been using HOME=%HOMEDRIVE%%HOMEPATH% for months, today is the first time it failed to expand. After going to *"Advanced System Settings > Environment Variables"* and looking but not changing anything, just pressing [ok], a fresh command shell shows the correct C:\users\myusername (earlier command shells did not). – matt wilkie Apr 12 2011 at 19:16
0

It is sufficient just to restart the cmd.exe, rather than rebooting.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.