Skip to content

File sync fails when coder_agent.dir is set to a non-home directory #238

@zedkipp

Description

@zedkipp

Current Behavior

File sync fails to install the Mutagen agent on workspaces where the coder_agent resource has a dir property set to a directory other than $HOME.

The error:

Image

I can see the agent was scp'd to $HOME/coder (repo location):

coder@upload-code-pastebin-dcbe:~$ grep -r mutagen-agent /home/coder/*
grep: /home/coder/coder/.mutagen-agentc8a65917-9e3a-40b6-9af9-947bfd9e27ac: binary file matches

Root Cause Investigation

This seems to be caused by an interaction between Coder Desktop's bundled Mutagen binary and the breaking change in coder/coder#21194, which made SFTP/SCP respect coder_agent.dir.

Prior to that PR, SCP landed files in $HOME while SSH sessions used dir. Mutagen's agent installation relied on SCP landing the binary in $HOME and then SSH executing it from $HOME. The original mismatch between SCP and SSH working directories was tracked in coder/coder#16568.

After the PR, both SCP and SSH now use dir. However, Mutagen appears to use an absolute $HOME-based path (/home/coder/.mutagen-agent<UUID>) when SCPing the binary, bypassing the dir setting. The SSH execution step then looks for the binary relative to dir (/home/coder/coder/), and the file isn't there.

SSHing into the workspace and running ls -la ~/.mutagen-agent* shows no files, confirming the binary never lands in $HOME.

Steps to Reproduce

  1. Use a Coder deployment running v2.30+ (which includes the SFTP/SCP dir change from PR #21194)
  2. Use a template that sets dir on coder_agent to a non-home directory, e.g.:

  resource "coder_agent" "dev" {
    arch = "amd64"
    os   = "linux"
    dir  = "/home/coder/coder"
  }

  (The dogfood "Write Coder on Coder" template does this)

  1. Open Coder Desktop -> File Sync
  2. Configure a sync session to the workspace
  3. Observe the error on "Installing agent..."

Expected Behavior

Mutagen installs its agent and file sync begins successfully, regardless of the coder_agent.dir setting.

Environment

  • Coder Desktop: v0.8.0 (macOS)
  • Coder deployment: v2.30.1+ (dogfood, running main)
  • Template: dogfood "Write Coder on Coder"
     (dir = local.repo_dir -> /home/coder/coder)
  • Workspace: Linux (amd64)

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions