WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Change default user in .wslconfig file

Open MarkusLoeffler01 opened this issue 3 years ago • 5 comments

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.

MarkusLoeffler01 avatar Dec 11 '22 18:12 MarkusLoeffler01

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.

Biswa96 avatar Dec 11 '22 19:12 Biswa96

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

MarkusLoeffler01 avatar Dec 11 '22 19:12 MarkusLoeffler01

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.

Biswa96 avatar Dec 11 '22 19:12 Biswa96

@MarkusLoeffler01 But I couldn't get to change the author ...you could try git commit --amend --author="Author Name <[email protected]>" instead.

elsaco avatar Dec 11 '22 20:12 elsaco

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

OneBlue avatar Dec 13 '22 00:12 OneBlue