You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue hatch is using virtualenvs interpreter discovery during creation of its virtual envs. The discovery also finds the Microsoft Store python shortcut. Even though the interpreter was not installed using the MS Store, this executable is used during discovery to run virtualenvs py_info.py script. In this setting, hatch is able to successfully create its venv (read: exit code 0), but the discovery returns a bunch of UnicodeDecodeErrors and spills them on the terminal ☹️
hatch env createException in thread Thread-6 (_readerthread):Traceback (most recent call last): File "C:\Users\axel-kah\AppData\Local\pyapp\data\hatch\5730184961401994386\1.13.0\python\Lib\threading.py", line 1073, in _bootstrap_inner self.run() File "C:\Users\axel-kah\AppData\Local\pyapp\data\hatch\5730184961401994386\1.13.0\python\Lib\threading.py", line 1010, in run self._target(*self._args, **self._kwargs) File "C:\Users\axel-kah\AppData\Local\pyapp\data\hatch\5730184961401994386\1.13.0\python\Lib\subprocess.py", line 1599, in _readerthread buffer.append(fh.read()) ^^^^^^^^^ File "<frozen codecs>", line 322, in decodeUnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 38: invalid start byteException in thread Thread-8 (_readerthread):Traceback (most recent call last): File "C:\Users\axel-kah\AppData\Local\pyapp\data\hatch\5730184961401994386\1.13.0\python\Lib\threading.py", line 1073, in _bootstrap_inner self.run() File "C:\Users\axel-kah\AppData\Local\pyapp\data\hatch\5730184961401994386\1.13.0\python\Lib\threading.py", line 1010, in run self._target(*self._args, **self._kwargs) File "C:\Users\axel-kah\AppData\Local\pyapp\data\hatch\5730184961401994386\1.13.0\python\Lib\subprocess.py", line 1599, in _readerthread buffer.append(fh.read()) ^^^^^^^^^ File "<frozen codecs>", line 322, in decodeUnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 38: invalid start byte
The root cause seems to be that virtualenv is spawning a subprocess for each interpreter it finds and has it execute the py_info.py script. On Windows this will also try the same with the "mysterious" C:\Users\axel-kah\AppData\Local\Microsoft\WindowsApps\python.exe. If python was not installed using MS Store, then this executable will return an error message using the infamous cp1252 encoding. When the OS is set to using a language like german, then this error message will contain german umlauts like ü which result in the UnicodeDecodeErrors.
Proposed Fix
Change the encoding to cp1252 when on windows when launching the subprocesses during discovery, instead of using utf-8 for all platforms.
I have verified the fix by locally patching a dev install of hatch and could submit a PR.
Environment
Provide at least:
OS: win11 (german language(!))
hatch 1.13.0
virtualenv 20.28.0
pip list of the host python where virtualenv is installed:
Issue
☹️
hatch
is usingvirtualenv
s interpreter discovery during creation of its virtual envs. The discovery also finds the Microsoft Store python shortcut. Even though the interpreter was not installed using the MS Store, this executable is used during discovery to run virtualenvspy_info.py
script. In this setting,hatch
is able to successfully create its venv (read: exit code 0), but the discovery returns a bunch ofUnicodeDecodeErrors
and spills them on the terminalThe root cause seems to be that
virtualenv
is spawning a subprocess for each interpreter it finds and has it execute thepy_info.py
script. On Windows this will also try the same with the "mysterious"C:\Users\axel-kah\AppData\Local\Microsoft\WindowsApps\python.exe
. If python was not installed using MS Store, then this executable will return an error message using the infamouscp1252
encoding. When the OS is set to using a language like german, then this error message will contain german umlauts likeü
which result in theUnicodeDecodeError
s.Proposed Fix
Change the encoding to
cp1252
when on windows when launching the subprocesses during discovery, instead of usingutf-8
for all platforms.I have verified the fix by locally patching a dev install of
hatch
and could submit a PR.Environment
Provide at least:
hatch
1.13.0virtualenv
20.28.0pip list
of the host python wherevirtualenv
is installed:Output of the virtual environment creation
Not applicable because venv is created implicitly by hatch.
The text was updated successfully, but these errors were encountered: