SchoofsKelvin / vscode-sshfs

Extension for Visual Studio Code: File system provider using SSH
GNU General Public License v3.0
543 stars 36 forks source link

Extra "/" in cd <root_path> in "Open remote SSH terminal" connection to windows #338

Closed nikolaqm closed 2 years ago

nikolaqm commented 2 years ago

Summary

Extra / in cd <root_path> in "Open remote SSH terminal" prevents terminal to open absolute path in Windows.

Steps to reproduce

I am connecting to OpenSSH server running on Windows. My workspace folder is connected well using the following URI in .code-workspace configuration

{
    "folders": [
        {
            "name": "main_pc",
            "uri": "ssh://host/C:\\Users\\user\\Documents"
        }
    ],
    "settings": {
    }
}

However if I click on "Open remote SSH terminal" connection to terminal fails because extensions tries to cd into /C:\Users\user... (note the leading /). Here is output of log:

[DEBUG]   Starting shell for runtime_1: cd "/C:\Users\user\Documents" && powershell
[DEBUG]   Terminal session closed: {"code":0,"status":"open"}

Confirmation of bug origin

To confirm this leading / is the problem I did the following: I specify as root folder in settings.json path manually without leading / like this:

{
    "sshfs.configs": [
      {
        "name": runtime",
        "newFileMode": "0o664",
        "host": "(deleted)",
        "username": "user",
        "label": "main_pc",
        "root": "C:\\Users\\user\\Documents",
        "privateKeyPath": "(deleted)",
        "port": 22,
        "flags": [
          "WINDOWS_COMMAND_SEPARATOR",
          "-CHECK_HOME"
        ],
        "terminalCommand": "powershell"
      }
    ],
  }

I can open remote SSH terminal directly clicking from SSH FS extension list of hosts.

[DEBUG]   Starting shell for runtime_1: cd "C:\Users\user\Documents" && powershell

However, again, if one mounts this as a folder, and then tries right-click on folder "Open remote SSH terminal" path will again have leading / inherited from URI.

Question

Can we resolve this bug somehow or find a workaround?

Can we maybe add extra flag that would be removing leading / from URI, or make existing flag WINDOWS_COMMAND_SEPARATOR also activate removal of leading / from root path used for cd when opening a new terminal?

Many thanks for your help!

SchoofsKelvin commented 2 years ago

Are you running a sshd server in WSL / WSL 2 or did you add the OpenSSH feature of which the server is running?

nikolaqm commented 2 years ago

Thank you for response! Connection is from Linux to Windows, specifically:

I am running SSH FS extension in containerized code-server that is on based on Ubuntu. That container is running on WSL2 on Windows 10 Pro.

Windows 10 Pro has OpenSSH server (and client) enabled.

I am connecting with SSH FS to the Windows Docker hosting OS ("host":"host.docker.internal") using key authentication.

SchoofsKelvin commented 2 years ago

This got fixed in 9410ac2 which'll be in the next version (i.e. v1.24.2 or, most likely, v1.25.0) of the extension. I've tested it both with and without having set Terminal command to powershell. It should now also auto-detect whether to use the WINDOWS_COMMAND_SEPARATOR flag, although specifying it (which would "override" it to true) wouldn't matter for Windows systems where the extension auto-detects it.

nikolaqm commented 2 years ago

Many thanks for rapid response @SchoofsKelvin ! And thank you for this very useful extension!