Skip to content

fix(ssh): build remote container workdir with path.Join - #1995

Open
Pramod-Pasala wants to merge 1 commit into
loft-sh:mainfrom
Pramod-Pasala:fix/windows-remote-workdir
Open

fix(ssh): build remote container workdir with path.Join#1995
Pramod-Pasala wants to merge 1 commit into
loft-sh:mainfrom
Pramod-Pasala:fix/windows-remote-workdir

Conversation

@Pramod-Pasala

Copy link
Copy Markdown

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.go builds the remote workdir with filepath.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 client filepath.Join produces \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 of filepath.Join.

Before / after (Windows 11 client → SSH provider workspace)

  • stock v0.6.15: ssh <ws>.devpod "pwd"/home/devpod (wrong dir, no error shown)
  • patched: 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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant