HOMEDRIVE and HOMEPATH environment variables may not be set on Windows 7+ #2417

Closed
opened 2015-05-04 21:46:05 +00:00 by daira · 1 comment
daira commented 2015-05-04 21:46:05 +00:00
Owner

The windows_expanduser function in source:src/allmydata/util/fileutil.py assumes that the current user account's home directory can be found by joining the %HOMEDRIVE% and %HOMEPATH% environment variables. This was correct on Windows XP, but on Windows 7+ (not sure about Vista), these variables are not set, resulting in this traceback:

Traceback (most recent call last):
  File "C:\Users\Buildslave\tahoe\Daira_Win7-64_py2_7\build\support\Scripts\tahoe.pyscript", line 16, in <module>
    load_entry_point('allmydata-tahoe==1.10.0.post340', 'console_scripts', 'tahoe')()
  File "C:\Users\Buildslave\tahoe\Daira_Win7-64_py2_7\build\support\Lib\site-packages\setuptools-0.6c16dev6.egg\pkg_resources.py", line 320, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "C:\Users\Buildslave\tahoe\Daira_Win7-64_py2_7\build\support\Lib\site-packages\setuptools-0.6c16dev6.egg\pkg_resources.py", line 2265, in load_entry_point
    return ep.load()
  File "C:\Users\Buildslave\tahoe\Daira_Win7-64_py2_7\build\support\Lib\site-packages\setuptools-0.6c16dev6.egg\pkg_resources.py", line 1998, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\scripts\runner.py", line 7, in <module>
    from allmydata.scripts.common import get_default_nodedir
  File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\scripts\common.py", line 20, in <module>
    path = abspath_expanduser_unicode(u"~/.tahoe")
  File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\util\fileutil.py", line 318, in abspath_expanduser_unicode
    path = expanduser(path)
  File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\util\fileutil.py", line 392, in expanduser
    return windows_expanduser(path)
  File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\util\fileutil.py", line 399, in windows_expanduser
    home_drive = windows_getenv(u'HOMEDRIVE')
  File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\util\fileutil.py", line 419, in windows_getenv
    % (err, name))
OSError: Windows error 203 attempting to read size of environment variable u'HOMEDRIVE'

https://tahoe-lafs.org/buildbot-tahoe-lafs/builders/Daira%20Win7-64%20py2.7/builds/17/steps/test-already-have-dep/logs/stdio

(Windows error 203 is ERROR_ENVVAR_NOT_FOUND.)

This is a regression since 1.10.0, therefore a release blocker. The correct behaviour is to use %USERPROFILE% instead.

The `windows_expanduser` function in source:src/allmydata/util/fileutil.py assumes that the current user account's home directory can be found by joining the %HOMEDRIVE% and %HOMEPATH% environment variables. This was correct on Windows XP, but on Windows 7+ (not sure about Vista), these variables are not set, resulting in this traceback: ``` Traceback (most recent call last): File "C:\Users\Buildslave\tahoe\Daira_Win7-64_py2_7\build\support\Scripts\tahoe.pyscript", line 16, in <module> load_entry_point('allmydata-tahoe==1.10.0.post340', 'console_scripts', 'tahoe')() File "C:\Users\Buildslave\tahoe\Daira_Win7-64_py2_7\build\support\Lib\site-packages\setuptools-0.6c16dev6.egg\pkg_resources.py", line 320, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "C:\Users\Buildslave\tahoe\Daira_Win7-64_py2_7\build\support\Lib\site-packages\setuptools-0.6c16dev6.egg\pkg_resources.py", line 2265, in load_entry_point return ep.load() File "C:\Users\Buildslave\tahoe\Daira_Win7-64_py2_7\build\support\Lib\site-packages\setuptools-0.6c16dev6.egg\pkg_resources.py", line 1998, in load entry = __import__(self.module_name, globals(),globals(), ['__name__']) File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\scripts\runner.py", line 7, in <module> from allmydata.scripts.common import get_default_nodedir File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\scripts\common.py", line 20, in <module> path = abspath_expanduser_unicode(u"~/.tahoe") File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\util\fileutil.py", line 318, in abspath_expanduser_unicode path = expanduser(path) File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\util\fileutil.py", line 392, in expanduser return windows_expanduser(path) File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\util\fileutil.py", line 399, in windows_expanduser home_drive = windows_getenv(u'HOMEDRIVE') File "c:\users\buildslave\tahoe\daira_win7-64_py2_7\build\src\allmydata\util\fileutil.py", line 419, in windows_getenv % (err, name)) OSError: Windows error 203 attempting to read size of environment variable u'HOMEDRIVE' ``` <https://tahoe-lafs.org/buildbot-tahoe-lafs/builders/Daira%20Win7-64%20py2.7/builds/17/steps/test-already-have-dep/logs/stdio> (Windows error 203 is `ERROR_ENVVAR_NOT_FOUND`.) This is a regression since 1.10.0, therefore a release blocker. The correct behaviour is to use %USERPROFILE% instead.
tahoe-lafs added the
code
major
defect
1.10.0
labels 2015-05-04 21:46:05 +00:00
tahoe-lafs added this to the 1.10.1 milestone 2015-05-04 21:46:05 +00:00
Daira Hopwood <daira@jacaranda.org> commented 2015-05-13 13:43:32 +00:00
Author
Owner

In /tahoe-lafs/trac-2024-07-25/commit/4794666df619fbfd7d36620163b51bda31322773:

On Windows, the user's home directory may be either %USERPROFILE% or %HOMEDRIVE%%HOMEPATH% depending on the Windows version. fixes ticket:2417

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
In [/tahoe-lafs/trac-2024-07-25/commit/4794666df619fbfd7d36620163b51bda31322773](/tahoe-lafs/trac-2024-07-25/commit/4794666df619fbfd7d36620163b51bda31322773): ``` On Windows, the user's home directory may be either %USERPROFILE% or %HOMEDRIVE%%HOMEPATH% depending on the Windows version. fixes ticket:2417 Signed-off-by: Daira Hopwood <daira@jacaranda.org> ```
tahoe-lafs added the
fixed
label 2015-05-13 13:43:32 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: tahoe-lafs/trac-2024-07-25#2417
No description provided.