Skip to content

Silent failure when applying .mounts during VM creation can drop all ~/.agent-vm/volumes entries #21

Description

@JeSuisUnCaillou

What happened

I added entries to ~/.agent-vm/volumes (extra host mounts), then ran agent-vm shell --reset on an existing per-project VM to pick them up. The reset completed with no errors or warnings, but inside the VM only the project directory was mounted — none of the ~/.agent-vm/volumes entries showed up (e.g. /home/caillou.linux/.claude, /home/caillou.linux/Pictures/Screenshots were both empty/missing).

Root cause

In _agent_vm_run (the VM-creation path), the mounts JSON is applied like this:

mounts_json=$(_agent_vm_build_mounts_json "$vm_name" "$host_dir")
local edit_args=()
edit_args+=(--set ".mounts = ${mounts_json}")
[[ -n "$memory" ]] && edit_args+=(--memory "$memory")
[[ -n "$cpus" ]]   && edit_args+=(--cpus "$cpus")
(cd /tmp && limactl edit "$vm_name" "${edit_args[@]}") &>/dev/null

_agent_vm_build_mounts_json itself produced correct JSON (verified separately — all volumes entries were parsed and included with the right location/mountPoint/writable fields). But the limactl edit ... &>/dev/null call that applies it swallows all output, including errors. In my case this limactl edit apparently failed on the first --reset (I can't tell why — no error was ever surfaced), leaving the VM with a bare lima.yaml .mounts array containing only the project directory.

I confirmed this by:

  1. Stopping the VM.
  2. Manually re-running the exact same limactl edit "$vm_name" --set ".mounts = <the same JSON>" command that _agent_vm_run had already run during --reset.
  3. This second attempt succeeded and applied the mounts correctly — limactl edit reported "configuration edited" with no error, and the mounts showed up correctly on the next VM start.

So the same command failed once and succeeded once, with identical inputs, and the first failure was completely silent because of &>/dev/null.

Suggested fix

Don't swallow stderr on the mount-applying limactl edit calls during VM creation (and the self-heal/repair path at a similar call site). At minimum, check the exit code and print a clear error (similar to how the existing project-mount writability check already fails loudly) so a failed ~/.agent-vm/volumes application doesn't silently leave the user with a VM missing all their extra mounts.

Environment

  • Host: Linux (Lima + QEMU backend)
  • agent-vm: latest main as of this report (includes the recent "mount guard-rails" commit a80ae34)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions