microsoft / microsoft/vscode-remote-release

Dev Containers extension misinterprets SSH URLs with custom ports as repository paths

Open
#10,203 0 comments 1 reaction 1 assignee View on GitHub

@chrmarti is already working on this.

Since Aug 31, 2024.

bug containers
Dominant language
Dockerfile
Stars
4.2k
Forks
469
Avg merge
1d 1h
Merged PRs (30d)
1

Description

  • VSCode Version: 1.92.2
  • Local OS Version: Windows 10 (19045.4780) x64
  • Remote OS Version: N/A
  • Remote Extension/Connection Type: Containers
  • Logs: Sadly there isn't much logging even when "trace" level is set.
[559 ms] Dev Containers 0.380.0 in VS Code 1.92.2 (fee1edb8d6d72a0ddff41e5f71a671c23ed924b9).
[558 ms] Initializing configuration support...
[559 ms] Internal initialization of dev container support package...
[1675 ms] Start: Run: git rev-parse --abbrev-ref --symbolic-full-name @{u}
[1855 ms] Stop (180 ms): Run: git rev-parse --abbrev-ref --symbolic-full-name @{u}

Steps to Reproduce:

  1. Clone or initialize a Git repository using an SSH URL with a custom port in this format: ssh://[<user>@]<host>:<port>/<path-to-git-repo> (e.g. ssh://git@domain.com:2222/wopss/vscode).
  2. On your local filesystem, create a directory structure that mirrors the remote repository path but does not include the port. For example, if the repository URL is ssh://git@domain.com:2222/wopss/vscode, the corresponding directory structure might look like:
📁 /path/to/repository-configurations
    📁 domain.com
        📁 wopss
            📁 vscode
                📁 .devcontainer
  1. Place your .devcontainer/devcontainer.json and related files in this mirrored directory structure.
  2. Update the Dev > Containers: Repository Configuration Paths setting in VS Code to point to the parent directory of your configuration files (e.g. /path/to/repository-configurations).
  3. Open the Git repository in VS Code.
  4. Run the command Dev Containers: Open Container Configuration File.

Actual behavior

VS Code prompts you to add a Container Configuration File, instead of automatically detecting the existing configuration files stored in the external repository configuration path.

Expected behavior

The Dev Containers extension should correctly identify and load configuration files stored in external directories, even when the repository is cloned using an SSH URL with a custom port.

Workaround

To work around this issue, include the custom port number in the directory structure within the repository configuration paths. For example, for the URL ssh://git@domain.com:2222/wopss/vscode, the directory structure should be:

📁 /path/to/repository-configurations
    📁 domain.com
        📁 2222
            📁 wopss
                📁 vscode
                    📁 .devcontainer

More information

According to Git clone documentation, the following URL formats are supported:

The following syntaxes may be used with them:
    ssh://[<user>@]<host>[:<port>]/<path-to-git-repo>
    git://<host>[:<port>]/<path-to-git-repo>
    http[s]://<host>[:<port>]/<path-to-git-repo>
    ftp[s]://<host>[:<port>]/<path-to-git-repo>

An alternative scp-like syntax may also be used with the ssh protocol:
    [<user>@]<host>:/<path-to-git-repo>

However, it appears that the Dev Containers extension treats URLs in the ssh:// format with a custom port similar to the scp-like syntax [<user>@]<host>:/<path-to-git-repo>, misinterpreting the port as part of the repository path and leading to issues with path resolution.

Does this issue occur when you try this locally?: Yes
Does this issue occur when you try this locally and all extensions are disabled?: Yes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.