Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
[Mutagen] fails to install it's agent on a Coder workspace were the dir property is set. For example, our Write Coder on Coder template uses:
resource "coder_agent" "dev" {
arch = "amd64"
os = "linux"
dir = local.repo_dir
env = {
OIDC_TOKEN : data.coder_workspace_owner.me.oidc_access_token,
}
startup_script_behavior = "blocking"
...
}
Mutagen works by scp'ing an agent file, then chmod'ing the file and executing it over SSH.
scp defaults to the user's home directory as the place to start any relative paths for scp. So the agent binary gets copied to ~/mutagen-agent<some UUID>. However, because we set dir in the terraform template, the default working directory for SSH is not the home directory, and so the SSH commands cannot locate the mutagen agent file.
Essentially this issue arises because Mutagen assumes scp and ssh will default to the home directory, or at least the same directory, but we break this assumption for SSH.
Options to fix:
-
Change our SSH server to also default scp to the
dirpath by default.
a. note that successful install moves the binary and doesn't leave the file in thedirdirectory, unless there is a failure -
Patch mutagen so that it uses explicit paths
Relevant Log Output
C:\Users\micha\mut\mut-dg> mutagen sync create --name=mut-dg . [email protected]:1:~/repos/coder
Setting agent executability...
Error: unable to connect to beta: unable to connect to endpoint: unable to dial agent endpoint: unable to install agent: unable to set agent executability: remote error: chmod: cannot access '.mutagen-agentf0875a2b-f7c7-401a-a799-e36178f5fa5b': No such file or directoryExpected Behavior
Mutagen copies its agent over and is able to file sync.
Steps to Reproduce
- Install Mutagen
- Install Coder Desktop or run
coder config-sshto get SSH working with your workspace - Push or use a template that sets the
dirproperty oncoder_agentto something other than the home directory - Create a file sync with the workspace using Mutagen
Environment
- Host OS: Windows 11
- Coder version: Coder v2.18.4+6125358
Additional Context
No response
Activity
spikecurtis commentedon Feb 24, 2025
Windows workspaces use Powershell as the shell for SSH sessions, unless Powershell is not available. That takes us back to at least 2008 with Windows 7. Since Powershell supports paths with
~meaning home directory, we could modify mutagen to use it for agent installs and it would work fine for all but the most ancient versions of Windows workspaces.matifali commentedon Feb 24, 2025
This is a reasonable bargain. Microsoft has ended support for Windows 7 at least 5 years ago (January 2020).
https://www.microsoft.com/en-us/windows/end-of-support
spikecurtis commentedon Feb 24, 2025
WIP branch that allows installs on our workspaces with
coder_agent.dirset. https://github.com/coder/mutagen/tree/spike/home-dirspikecurtis commentedon Mar 3, 2025
One idea was to configure
mutagento send an environment variable to the SSH server to tell it to ignore thecoder_agent.dirproperty for the session. However,mutagenspecifically disallows and does not support environment variables in SSH targets. So, this strategy would not allow us to avoid forkingmutagen.cc @deansheather