vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

[Remote-SSH Bug]: Linux connected to Windows PATH lookup broken

Open lukts30 opened this issue 2 years ago • 1 comments

Is there an existing issue for this bug?

  • [X] I have searched the existing issues

Required Troubleshooting Steps

  • [X] I have followed these troubleshooting steps
  • [ ] I have tried both values of the remote.SSH.useLocalServer setting

Connect Locally

It connects successfully

->

No response

Expected Behavior

Explicitly set PATH env should work (task should execute successfully).

  • Local Windows vscode in the Windows VM does work.
  • Windows connected to Windows over Remote - SSH extension does work.
  • Linux connected to Windows over Remote - SSH extension does not work.

Steps To Reproduce

  1. Create a tasks.json with following content:
{
	"version": "2.0.0",
	"tasks": [
		{
            "label": "diagnostic",
            "type": "process",
            "options": {
                "cwd": "c:\\",
                "env": {
                    "PATH": "C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\system32\\config\\systemprofile\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\User\\AppData\\Local\\Microsoft\\WindowsApps;"
                }
            },
            "command": "whoami",
            "problemMatcher": []
        }
	]
}
  1. Run the task.
  2. Fails with:
  • The terminal process failed to launch: Path to shell executable "c:\whoami" does not exist.
  • Linux connected to Windows over Remote - SSH extension does not work.
  1. It looks like findExecutable is called twice first with the paths entries correctly split (";") and a second time incorrectly split (":").

Remote-SSH Log

Remote-SSH Log

[21:05:54.175] Log Level: 2
[21:05:54.182] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a223139322e3136382e3132322e323237222c2275736572223a2275736572227d", attempt 1
[21:05:54.182] "remote.SSH.useLocalServer": true
[21:05:54.182] "remote.SSH.path": undefined
[21:05:54.182] "remote.SSH.configFile": undefined
[21:05:54.182] "remote.SSH.useFlock": true
[21:05:54.182] "remote.SSH.lockfilesInTmp": false
[21:05:54.182] "remote.SSH.localServerDownload": auto
[21:05:54.183] "remote.SSH.remoteServerListenOnSocket": false
[21:05:54.183] "remote.SSH.showLoginTerminal": false
[21:05:54.183] "remote.SSH.defaultExtensions": []
[21:05:54.183] "remote.SSH.loglevel": 2
[21:05:54.183] "remote.SSH.enableDynamicForwarding": true
[21:05:54.183] "remote.SSH.enableRemoteCommand": false
[21:05:54.183] "remote.SSH.serverPickPortsFromRange": {}
[21:05:54.183] "remote.SSH.serverInstallPath": {}
[21:05:54.184] VS Code version: 1.77.0
[21:05:54.184] Remote-SSH version: [email protected]
[21:05:54.184] linux x64
[21:05:54.185] SSH Resolver called for host: [email protected]
[21:05:54.185] Setting up SSH remote "192.168.122.227"
[21:05:54.187] Acquiring local install lock: /tmp/vscode-remote-ssh-c412d033-install.lock
[21:05:54.187] Looking for existing server data file at /home/lukas/.config/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-c412d033-7f329fe6c66b0f86ae1574c2911b681ad5a45d63-0.98.0/data.json
[21:05:54.188] Found local server running: {"remoteListeningOn":{"port":50325},"osReleaseId":"windows","arch":"x64","sshAuthSock":"","platform":"windows","connectionToken":"aaa1aa11-11aa-1111-111a-111111111111","pid":52433,"ipcHandlePath":"/run/user/1000/vscode-ssh-askpass-f06fb05357cc8b0d3f77650e7efb732c6ff46d28.sock","socksPort":41989,"startupTime":1680375924673}
[21:05:54.192] Found running server - short-circuiting install
[21:05:54.195] Starting forwarding server. localPort 33099 -> socksPort 41989 -> remotePort 50325
[21:05:54.195] Forwarding server listening on 33099
[21:05:54.195] Waiting for ssh tunnel to be ready
[21:05:54.195] [Forwarding server 33099] Got connection 0
[21:05:54.196] Tunneled 50325 to local port 33099
[21:05:54.196] Resolved "ssh-remote+7b22686f73744e616d65223a223139322e3136382e3132322e323237222c2275736572223a2275736572227d" to "127.0.0.1:33099"
[21:05:54.204] ------




[21:05:54.208] [Forwarding server 33099] Got connection 1
[21:05:54.221] [Forwarding server 33099] Got connection 2

Anything else?

I added: console.log("findExecutable " + "cmd: " + I + "\nenv: " + E + "\ncwd: " + C); to async function S(I,C,E) (findExecutable) in C:\Users\User.vscode-server\bin\7f329fe6c66b0f86ae1574c2911b681ad5a45d63\out\vs\workbench\api\node\extensionHostProcess.js

[Extension Host] findExecutable cmd: whoami
env: C:\windows\system32,C:\windows,C:\windows\System32\Wbem,C:\windows\System32\WindowsPowerShell\v1.0\,C:\windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps,C:\Users\User\AppData\Local\Microsoft\WindowsApps,
cwd: c:\
console.ts:137 [Extension Host] findExecutable cmd: whoami
env: C,\windows\system32;C,\windows;C,\windows\System32\Wbem;C,\windows\System32\WindowsPowerShell\v1.0\;C,\windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C,\Users\User\AppData\Local\Microsoft\WindowsApps;
cwd: c:\

lukts30 avatar Apr 01 '23 19:04 lukts30

Has this been fixed yet?

sascharo avatar Aug 21 '24 15:08 sascharo

@alexr00 I think you may have some context on how this works looking at the provided link to findExecutable

joshspicer avatar Dec 11 '24 19:12 joshspicer

@joshspicer you're right that I was involved in findExecutable. @meganrogge do you want me to take a look at this since findExecutable is part of tasks land? Based on @lukts30 findings, the issue seems to be with how tasks is calling findExecutable. I would guess that since the split is using the renderer's path.delimiter here that might be part of the problem.

alexr00 avatar Dec 12 '24 10:12 alexr00

Yes @alexr00 , that would be great. Note that there was just this PR that modified findExecutable https://github.com/microsoft/vscode/pull/228373

meganrogge avatar Dec 12 '24 17:12 meganrogge

@meganrogge I made a build and tested the fix out when connecting linux -> Windows. https://github.com/microsoft/vscode/pull/236047

alexr00 avatar Dec 13 '24 13:12 alexr00

I've tested that the provided task executes successfully in the following cases:

  1. macOS -> Windows ✅
Image
  1. linux -> Windows ✅
Image

Thank you @alexr00 @meganrogge!

joshspicer avatar Jan 30 '25 00:01 joshspicer