Vscode-remote-release: wsl: allow to run with a non-default user

Created on 11 May 2019  路  12Comments  路  Source: microsoft/vscode-remote-release

Issue Type: Bug

As part of my WSL instance, I had to create a user to properly setup nvm for configuring nodejs and npm. I could properly create the user and access it via the provided terminal in remote VS Code but can't open files with 'code-insiders .' or through other means.

I used this tutorial: Developing in the Windows Subsystem For Linux with VS Code to set up the remote development.

Note: by default the VS Code Insiders file explorer shows the root (WSL) folder

Expected

'code-insiders .'
Should open the given directory in the vs code insiders explorer when logged in as a non-root user(w/ sudo privileges)

Actual

'code-insiders .'
code-insiders: command not found

This issue only happens when you're logged in as a given user. It works as expected when you're a root user.

Extension version: 0.34.0
VS Code version: Code - Insiders 1.34.20-insider (57b550c559b945eb9d871dbf2b2e4cb9e31e2551, 2019-05-10T17:36:45.765Z)
OS version: Windows_NT x64 10.0.17134
Remote OS version: Linux x64 4.4.0-17134-Microsoft


System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz (12 x 3696)|
|GPU Status|2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|31.91GB (22.40GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|

|Item|Value|
|---|---|
|Remote|WSL|
|OS|Linux x64 4.4.0-17134-Microsoft|
|CPUs|Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz (12 x 3696)|
|Memory (System)|31.91GB (22.40GB free)|
|VM|0%|


feature-request plan-review wsl

Most helpful comment

The WSL remote extension currently always uses the default user.

WSL allows to change the default user for a distro in two ways:

Following the steps in description, above, it seems there are additional issues in WSL when creating a new user:

  • create a new user in WSL (adduser).
  • after switching to the user (su), the env PATH does not include the windows path. This looks like a WSL issue. That's why code-insiders . is not working.

All 12 comments

The WSL remote extension currently always uses the default user.

WSL allows to change the default user for a distro in two ways:

Following the steps in description, above, it seems there are additional issues in WSL when creating a new user:

  • create a new user in WSL (adduser).
  • after switching to the user (su), the env PATH does not include the windows path. This looks like a WSL issue. That's why code-insiders . is not working.

@aeschli Should I create an issue for WSL about including the windows path after switching to the user?

@LuisOsta Yes, that would be great.

Can Remote-WSL allow for configuring wsl args? Or use my-distro.exe instead of wsl.exe to run WSL? For some reason wsl.exe starts as root and if I could change args to -u my-user my problem would be fixed.

Can Remote-WSL allow for configuring wsl args? Or use my-distro.exe instead of wsl.exe to run WSL? For some reason wsl.exe starts as root and if I could change args to -u my-user my problem would be fixed.

Same problem. It looks like that the Remote-WSL runs the wslServer.shusing the default user. And the default user of an imported distro is root. Changing the default user should resolve this.

After some research, got a solution from https://github.com/microsoft/WSL/issues/4276#issuecomment-509364493

For the record there is a .wslconfig entry by now for the default user: https://docs.microsoft.com/en-us/windows/wsl/release-notes#build-18980
But that doesn't solve the original problem I guess.

Problem still exists

I'm currently trying to use code . on another user, but it only works for my default user. Is this intended behaviour, or is there a way around it?

Basically,
open distro to default user -> run code . (works) -> su - otheruser -> run code . (doesn't work)

I just want to add that running code-insiders . from my non-default WSL user downloads the vscode-server to the correct location (~/.vscode-server-insiders), and launches VSCode. But then the app connects to WSL using the default user, downloads the vscode-server again (this time to /home/<default-user>/.vscode-server-insiders) and runs from there.

Currently there are plans to solve this problem?

Np plans at the moment as I don't know how the UX would look like. I'd rather avoid an additional picker or input dialog.
Maybe a settings?

So now that I'm not running VSCode Insiders I'm no longer running into this issue. While I think maybe putting something on settings would be helpful. I think since there's a terminal we can probably avoid that unless there's a lot of people facing these issues.

Was this page helpful?
0 / 5 - 0 ratings