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
- Create a folder with a file, e.g.,
migrations/001-init/file.sql
- Move
file.sql to another folder (e.g., migrations/002-changed/)
- Run
garden deploy
- Observe that
.garden/build/migrations/001-init still exists as an empty directory
Workaround
You can avoid the issue in three different ways:
-
Delete .garden/ manually after cleanup or after moving files:
-
Use rsync instead of Mutagen for syncing:
GARDEN_K8S_BUILD_SYNC_MODE=rsync GARDEN_LEGACY_BUILD_STAGE=true garden deploy
-
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
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/buildshould be removed when files inside them are moved or deleted, reflecting the actual state of the source directory.Reproducible example
migrations/001-init/file.sqlfile.sqlto another folder (e.g.,migrations/002-changed/)garden deploy.garden/build/migrations/001-initstill exists as an empty directoryWorkaround
You can avoid the issue in three different ways:
Delete
.garden/manually after cleanup or after moving files:Use
rsyncinstead of Mutagen for syncing:Patch the Garden source code to use
two-way-resolvedsync mode instead ofone-way-replicaat:garden/core/src/plugins/kubernetes/container/build/common.ts
Line 143 in ee31fdb
Suggested solution(s)
Change the default sync mode in the Garden source code to use
two-way-resolvedinstead ofone-way-replica, or introduce a mechanism to clean up empty directories left in.garden/buildafter 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