Skip to content

ssh: explicitly set ~ for home directory unless using cmd.exe - #1

Merged
spikecurtis merged 6 commits into
mainfrom
spike/home-dir
Mar 17, 2025
Merged

spikecurtis merged 6 commits into
mainfrom
spike/home-dir

Conversation

@spikecurtis

Copy link
Copy Markdown

Fixes coder/coder#16568

This PR uses an explicit ~ in SSH paths to ensure that the mutagen agent is installed in the home directory, even when the SSH default directory is some other directory, as is the case for some Coder workspaces.

Note that this breaks the Docker transport on Linux, since the Docker transport also sets the explicit home directory. If we ever wanted to upstream this, we would need a better fix, but for Coder's purposes we are only interested in SSH-based file sync.

The problem is that while mutagen defines a Transport interface, the abstraction is very leaky: in the case of Docker, mutagen actively probes the endpoint to figure out the home directory, and then adds it under the covers. In the case of SSH, mutagen assumes (incorrectly in Coder's case) that the default directory is the home directory. The implementations also differ in how they handle different operating systems, with Docker using probing, while SSH depends on the calling function to retry with different requests that might succeed on different operating systems.

For now, I just don't think it's worth making a proper fix that refactors the use of the Transport interface, given that we don't care about Docker support. I raised an issue on the main mutagen repo asking if they would consider an PR and got no answer. While the repository is still getting some maintenance, it mainly consists of dependency updates. I don't think the team is able to devote time to considering a larger fix for us.

@deansheather deansheather left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. I guess Mutagen doesn't have a great cmd/powershell test suite?

Comment thread pkg/agent/dial.go Resolved
Comment thread pkg/agent/dial.go Resolved
Comment thread pkg/process/errors.go
// windowsPowershellCommandNotFoundFragment is a fragment of the error output
// returned on Windows systems running Powershell when a command cannot be
// found.
windowsPowershellCommandNotFoundFragment = "is not recognized as the name of a cmdlet, function, script file, or operable program."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it would break if you have a different OS language, but I guess mutagen was already doing similar error string checks previously and I can't really think of a better way to accomplish this. So it's probably fine for now

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.

coder_agent dir property breaks Mutagen file sync from Windows

4 participants