Skip to content

coder_agent dir property breaks Mutagen file sync from Windows #16568

Closed
coder/mutagen
#1

Description

@spikecurtis

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:

  1. Change our SSH server to also default scp to the dir path by default.
    a. note that successful install moves the binary and doesn't leave the file in the dir directory, unless there is a failure

  2. 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 directory

Expected Behavior

Mutagen copies its agent over and is able to file sync.

Steps to Reproduce

  1. Install Mutagen
  2. Install Coder Desktop or run coder config-ssh to get SSH working with your workspace
  3. Push or use a template that sets the dir property on coder_agent to something other than the home directory
  4. 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

  1. added
    networking
    s2
    on Feb 14, 2025
  2. spikecurtis commented on Feb 24, 2025

    @spikecurtis
    CollaboratorAuthor

    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.

  3. matifali commented on Feb 24, 2025

    @matifali
    Contributor

    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

  4. self-assigned this
    on Feb 24, 2025
  5. spikecurtis commented on Feb 24, 2025

    @spikecurtis
    CollaboratorAuthor
  6. spikecurtis commented on Mar 3, 2025

    @spikecurtis
    CollaboratorAuthor

    One idea was to configure mutagen to send an environment variable to the SSH server to tell it to ignore the coder_agent.dir property for the session. However, mutagen specifically disallows and does not support environment variables in SSH targets. So, this strategy would not allow us to avoid forking mutagen.

    cc @deansheather

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

networkings2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions