WSL: Windows doesn't have permission to write new user files
Solution 1:
You seem to be running into this issue. Namely, VSCode always runs as the default user in a WSL session.
You should be able to confirm this with a simple whoami
in the VSCode terminal. Even though you started it from the work
user, it will likely be running as hellmers
.
For your particular use case, I would think, you could give your hellmers
user access to the work
user folder. Seems to work for me:
sudo usermod -aG work hellmers
chmod -R g+wrx /home/work
If you really do need to run VSCode as the work
user, per that Github issue, you'll need to change the default user for the WSL instance. The recommended way of doing this is by creating a /etc/wsl.conf
(as sudo
) with the following contents:
[user]
default=work
Then stopping your WSL instance with wsl --terminate <distroname
and restarting.
VSCode should run as the work
user at that point.
It's not pretty, nor convenient. But if you must run VSCode as a different user, you'll need to make that user the default for the WSL instance.
Another possible alternative would be to set up separate WSL instances, one with hellmers
as the default and the other, of course, with work
. There's nothing wrong with keeping around multiple "utility" WSL instances as you need them.