Change default user in .wslconfig file
Is your feature request related to a problem? Please describe.
I have multiple github accounts for different purposes. So it started with VSCode using different git credentials and different authors. Different credentials was possible by using the terminal and switching the user. But I couldn't get to change the author. And since there was no way to start VSCode WSL with an user other than the default one, I tried making a whole new Windows User. Since I want all users to use the same state, I created a symlink to the LocalState folder, so both profiles use the same wsl disk.
But then I figured that the default user is saved in /etc/wsl.conf, and not saved per user. So I can't set a default user
Describe the solution you'd like
To be able to configure a default user for each .wslconfig file, so each Windows User has his own WSL-User in the same distro/VM, which would make a multi-user Windows system way more friendly for WSL-Developers
Describe alternatives you've considered
An alternative would be to make a completely new WSL-VM for each user and mounting the main vhdx file, where all the projects, etc. reside, which would be very space-inefficient.
there was no way to start VSCode WSL with an user other than the default one
Should not this be a feature request in VSCode instead of WSL? The main limitation is in VSCode remote extension.
there was no way to start VSCode WSL with an user other than the default one
Should not this be a feature request in VSCode instead of WSL? The main limitation is in VSCode remote extension.
Could be too, but I thought being able to use it in the .wslconfig directly would be a better and more global solution so not only VSCode could make use of it
I thought being able to use it in the .wslconfig directly would be a better
I am not sure if that would be a better solution. LxssManager reads .wslconfig file before launching any WSL2 VM instance. So, if .wslconfig has a default WSL2 user it would be set for all distributions in WSL2. Just a thought 💭
...so not only VSCode could make use of it
If any program want to change user in WSL2 it can use wsl.exe --user command.
@MarkusLoeffler01 But I couldn't get to change the author ...you could try git commit --amend --author="Author Name <[email protected]>" instead.
Thank you for the suggestion @MarkusLoeffler01.
Indeed users are configurated via /etc/wsl.conf because each distro has a default user. Setting a default user in .wslconfig would conflict with so I don't think this is something we would want to support.
As @Biswa96 suggested, I think this should be a feature request for VSCode instead, since they can pass --user when calling into WSL instead