Skip to content

[Bug]: Mutagen sync leaves empty directories in .garden/build causing desync (e.g. with Prisma) #7573

@nullxx

Description

@nullxx

Bug

Current behavior

When using Garden with the default build system (Mutagen), file deletions are propagated to .garden/build, but empty directories left behind after file moves or deletions are not removed. This results in outdated, empty folders being left in .garden/build, which can cause problems with tools like Prisma that rely on accurate directory structures (e.g., prisma/migrations).

Expected behavior

Empty directories in .garden/build should be removed when files inside them are moved or deleted, reflecting the actual state of the source directory.

Reproducible example

  1. Create a folder with a file, e.g., migrations/001-init/file.sql
  2. Move file.sql to another folder (e.g., migrations/002-changed/)
  3. Run garden deploy
  4. Observe that .garden/build/migrations/001-init still exists as an empty directory

Workaround

You can avoid the issue in three different ways:

  1. Delete .garden/ manually after cleanup or after moving files:

    rm -rf .garden
  2. Use rsync instead of Mutagen for syncing:

    GARDEN_K8S_BUILD_SYNC_MODE=rsync GARDEN_LEGACY_BUILD_STAGE=true garden deploy
  3. Patch the Garden source code to use two-way-resolved sync mode instead of one-way-replica at:

Suggested solution(s)

Change the default sync mode in the Garden source code to use two-way-resolved instead of one-way-replica, or introduce a mechanism to clean up empty directories left in .garden/build after sync.

Additional context

This behavior breaks workflows that rely on a strict directory structure such as Prisma's migration system. These leftover empty folders can cause unexpected issues.

Your environment

  • OS: Fedora Linux 42 (Workstation Edition)
  • How I'm running Kubernetes: EKS
garden version
garden version: 0.13.61

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions