Skip to content

fix: persist Homebrew across workspace restarts, fix brew upgrade EXDEV error - #186

Merged
rfay merged 1 commit into
mainfrom
20260727_homebrew_persist
Jul 27, 2026
Merged

fix: persist Homebrew across workspace restarts, fix brew upgrade EXDEV error#186
rfay merged 1 commit into
mainfrom
20260727_homebrew_persist

Conversation

@rfay

@rfay rfay commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds a per-workspace named Docker volume (coder-<owner>-<workspace>-linuxbrew) mounted at /home/linuxbrew in all three templates (freeform, drupal-core, drupal-contrib), so brew install/brew upgrade done inside a workspace survives coder stop/coder start. Previously /home/linuxbrew lived on the container's ephemeral root filesystem and any manual Homebrew changes were silently lost.
  • Relocates HOMEBREW_CACHE to /home/linuxbrew/.cache/Homebrew in image/Dockerfile (was defaulting to $HOME/.cache/Homebrew, a different filesystem than the Cellar), fixing a cross-device link (EXDEV) error when hardlinking a downloaded bottle into the Cellar.
  • Adds sudo chown -R coder:coder /home/linuxbrew to each template's startup script, next to the existing /home/coder chown.
  • Bumps VERSION to v0.5 since this requires an image rebuild.
  • Adds a linuxbrew_volume_created test to all three tests/validate.tftest.hcl files.
  • Updates CLAUDE.md's Volume Strategy section.

Test plan

  • terraform fmt -recursive -check -diff — clean
  • terraform validate for all three templates — clean
  • terraform test for all three templates — 7/7/12 passed
  • Rebuild + push the Docker image (make build-and-push, must run on an amd64 host) before pushing templates, since the Dockerfile changed
  • End-to-end verification on a real deployment: rebuilt image + brew upgrade + coder stop/coder start cycle

🤖 Generated with Claude Code

…EV error

Homebrew (/home/linuxbrew/.linuxbrew) lived on the container's ephemeral
image/root filesystem in all three templates, not on any persisted volume.
Two consequences:

1. brew upgrade/brew install could fail outright with a cross-filesystem
   link error (EXDEV). Homebrew's default cache ($HOME/.cache/Homebrew)
   resolves to /home/coder/.cache/Homebrew -- a different, volume-mounted
   filesystem than the Cellar at /home/linuxbrew/.linuxbrew. Renaming a
   downloaded bottle across that boundary throws EXDEV.
2. Even when an upgrade succeeded, it didn't stick. docker_container.workspace
   is destroyed and recreated fresh from the image on every workspace
   stop/start, so anything installed/upgraded on the container's own root
   filesystem was silently lost on the next restart -- only the bind-mounted
   /home/coder and the dind-cache volume survived.

Fix both, in all three templates:
- Relocate HOMEBREW_CACHE to /home/linuxbrew/.cache/Homebrew via a Dockerfile
  ENV, so cache and Cellar are guaranteed to be on the same filesystem.
- Add a new per-workspace docker_volume mounted at /home/linuxbrew, matching
  the existing dind-cache pattern (unconditional, not gated by start_count,
  so it survives stop/start). Docker auto-populates a fresh named volume from
  the image's existing directory contents on first mount, so no manual
  seed-copy step is needed -- just an ownership fix mirroring the existing
  /home/coder chown.

Bumps VERSION to v0.5 to match the image already rebuilt and pushed on amd64
with this Dockerfile change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-27 14:30 UTC

@rfay
rfay merged commit c893dab into main Jul 27, 2026
16 checks passed
@rfay
rfay deleted the 20260727_homebrew_persist branch July 27, 2026 14:29
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.

1 participant