fix(ssh): build remote container workdir with path.Join - #1995
Open
Pramod-Pasala wants to merge 1 commit into
Open
fix(ssh): build remote container workdir with path.Join#1995Pramod-Pasala wants to merge 1 commit into
Pramod-Pasala wants to merge 1 commit into
Conversation
The remote workdir is passed to the container's ssh-server via --workdir, so it must always use forward slashes regardless of the client OS. filepath.Join produces backslashes on Windows (e.g. '\\workspaces\\myproject'), which the Linux ssh-server cannot resolve; the session silently falls back to the user's home directory. Verified on a Windows client against an SSH-provider workspace: stock: 'ssh <ws>.devpod pwd' -> /home/devpod (wrong dir) patched: -> /workspaces/devpod Refs loft-sh#972
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
devpod ssh/ VS Code Remote-SSH sessions ignore the workspace workdir on Windows clients and silently land in the container's home directory instead of the cloned workspace.Root cause
cmd/ssh.gobuilds the remote workdir withfilepath.Join("/workspaces", workspace). That path is passed to the Linux container's ssh-server via--workdir, so it must always use forward slashes. On a Windows clientfilepath.Joinproduces\workspaces\myproject, which the Linux side cannot resolve — the session then silently falls back to the user's home directory.Fix
Use
path.Join(always forward slashes) instead offilepath.Join.Before / after (Windows 11 client → SSH provider workspace)
ssh <ws>.devpod "pwd"→/home/devpod(wrong dir, no error shown)ssh <ws>.devpod "pwd"→/workspaces/devpod(correct)Same result on a freshly created workspace (
devpod up https://github.com/loft-sh/devpod): stock lands in/home/devpod, patched in/workspaces/devpod.Refs #972