VSCode Extension overrides LANG settings unconditionally, leading to non-working Python locale
Flameeyes opened this issue · comments
I'm not sure how to gather more debug information, but the VSCode extension appears to sometimes not detect correctly that the open folder is a valid Sapling checkout:
Not a valid repository
/home/flameeyes/repos/unpaper is not a valid Sapling repository. Clone or init a repository to use ISL.
(venv) flameeyes@Gamestation:~/repos/unpaper$ pwd
/home/flameeyes/repos/unpaper
(venv) flameeyes@Gamestation:~/repos/unpaper$ sl status
M imageprocess.c
M imageprocess.h
M meson.build
M unpaper.c
? imageprocess/deskew.c
? imageprocess/deskew.h
opening a different folder and going back to the original appears to fix it, but I have no idea why is that even the case.
sigh I was looking everywhere and couldn't find that.
I can't reproduce it right now, it might have something to do with a cold open? I'll see if I can reproduce this tomorrow, usually I seem to get it once every so often, and when I do I'll post here!
Hah, I just found a failure after returning from (computer's) sleep:
Failed to fetch commits
Command failed with exit code 1: sl log --template {node} {desc|firstline} {author} {committerdate|isodatesec} {phase} {bookmarks % '{bookmark}\0'} {remotenames % '{remotename}\0'} {parents % "{node}\0"} {ifcontains(rev, revset('.'), '@')} {file_adds|json} {file_mods|json} {file_dels|json} {mutations % "{operation}:{successors % "{node}"},"} {predecessors % "{node},"} {if(phabdiff, phabdiff, github_pull_request_number)} {desc} <<COMMIT_END_MARK>> --rev smartlog(((interestingbookmarks() + heads(draft())) & date(-14)) + .) --noninteractive --config extensions.blackbox=! Traceback (most recent call last): File "static:sapling", line 64, in run from . import dispatch File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "static:sapling.dispatch", line 27, in <module> from . import ( File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "static:sapling.cmdutil", line 29, in <module> from . import ( File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "static:sapling.crecord", line 32, in <module> locale.setlocale(locale.LC_ALL, "") File "/usr/lib/python3.10/locale.py", line 620, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting
You are here
Failed to fetch Uncommitted Changes
Command failed with exit code 1: sl status -Tjson --copies --noninteractive --config extensions.blackbox=! --config fsmonitor.watchman-query-lock=True Traceback (most recent call last): File "static:sapling", line 64, in run from . import dispatch File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "static:sapling.dispatch", line 27, in <module> from . import ( File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "static:sapling.cmdutil", line 29, in <module> from . import ( File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "static:sapling.crecord", line 32, in <module> locale.setlocale(locale.LC_ALL, "") File "/usr/lib/python3.10/locale.py", line 620, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting
[Open](https://github.com/unpaper/unpaper/pull/148)
2
Uncommit
Split
[Merged](https://github.com/unpaper/unpaper/pull/147)
Goto
[Merged](https://github.com/unpaper/unpaper/pull/146)
Goto
Edit stack
Goto
Load more commits
sl pull
Traceback (most recent call last):
File "static:sapling", line 64, in run
from . import dispatch
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "static:sapling.dispatch", line 27, in <module>
from . import (
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "static:sapling.cmdutil", line 29, in <module>
from . import (
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "static:sapling.crecord", line 32, in <module>
locale.setlocale(locale.LC_ALL, "")
File "/usr/lib/python3.10/locale.py", line 620, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
Commit Info
But the locale.setlocale(locale.LC_ALL, "")
should reasonably work. I can't imagine why it wouldn't.
I think I found something, but it might even be a VSCode/WSL problem, I'm not sure.
Most of the invocations of sl
get an environment of LANG=C.UTF-8
, which work just fine. But in some cases (usually coming back from sleep it seems, and possibly at first boot up), they have LANG=en_US.utf-8
— as far as I can tell this is only true for invocations for the Smartlog, other processes spawned by the VSCode server component don't seem to set it to anything but C.UTF-8
which is the default it seems.
When LANG=en_US.utf-8
is set, I can reproduce this:
(venv) flameeyes@Gamestation:~/env-vars$ python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, "")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/locale.py", line 620, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
Thanks for the info! I think you can enable the locale in WSL via:
sudo sed -i "s/# en_US.UTF/en_US.UTF/" /etc/locale.gen
sudo locale-gen
The setlocale logic might be unnecessary. If so, we might want to remove it.
Yeah I'm unfortunately quite aware of the glibc locale generation, so that as a workaround would work.
But I also just found
sapling/addons/isl-server/src/Repository.ts
Line 1211 in c2d958b
Thanks! I'll update the related logic to not assume en_US.utf-8
is valid.
I think the easiest would be to use C.UTF-8 which AFAIR is always present, as it doesn't require generating any locale.