Carry the loader's .git fix over
The vendored copy, matching modal 6718f3d: the image build drops $workdir/.git, so a worktree's gitdir pointer never reaches a container. Both frq containers were working around it in their own commands; they no longer have to, and an interactive shell in the same image gets it too. This is the drift the vendoring was always going to have. Two copies, one fix, applied by hand. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
85852e8 parent: c20643a modified
.modal/_loader.py +9 -1 | @@ -1,6 +1,7 @@ | ||
| 1 | 1 | """Turn a `container.toml` into a `modal.Image` and a `modal.App`. |
| 2 | 2 | |
| 3 | -Every container under `containers/` is a directory with a `container.toml` and | |
| 3 | +Every container -- under `containers/` here, `.modal/` in a repo that merely | |
| 4 | +builds itself on Modal -- is a directory with a `container.toml` and | |
| 4 | 5 | a stub `container.py`. See `spec.md` for the keys; this file is what reads |
| 5 | 6 | them. Nothing here is Modal-specific configuration in its own right -- each |
| 6 | 7 | spec key maps onto a documented Modal argument, and the mapping is meant to |
| @@ -207,6 +208,13 @@ class Container: | ||
| 207 | 208 | else: |
| 208 | 209 | image = image.add_local_file(src, dest, copy=True) |
| 209 | 210 | |
| 211 | + # A repo copied in brings its `.git` along, and in a worktree that is a | |
| 212 | + # *file* holding `gitdir: <path on the machine that copied it>`. Nix | |
| 213 | + # believes it and goes looking for a checkout that is not there -- | |
| 214 | + # `nix develop` and `nix build .#x` both die before evaluating | |
| 215 | + # anything. Nothing in a container wants the git metadata, so it goes. | |
| 216 | + image = image.run_commands(f"rm -rf {self.workdir}/.git") | |
| 217 | + | |
| 210 | 218 | if commands := build.get("commands", []): |
| 211 | 219 | image = image.run_commands(*commands) |
| 212 | 220 | |
| @@ -1,6 +1,7 @@ | |||
| 1 | """Turn a `container.toml` into a `modal.Image` and a `modal.App`. | 1 | """Turn a `container.toml` into a `modal.Image` and a `modal.App`. |
| 2 | 2 | ||
| 3 | -Every container under `containers/` is a directory with a `container.toml` and | 3 | +Every container -- under `containers/` here, `.modal/` in a repo that merely |
| 4 | +builds itself on Modal -- is a directory with a `container.toml` and | ||
| 4 | a stub `container.py`. See `spec.md` for the keys; this file is what reads | 5 | a stub `container.py`. See `spec.md` for the keys; this file is what reads |
| 5 | them. Nothing here is Modal-specific configuration in its own right -- each | 6 | them. Nothing here is Modal-specific configuration in its own right -- each |
| 6 | spec key maps onto a documented Modal argument, and the mapping is meant to | 7 | spec key maps onto a documented Modal argument, and the mapping is meant to |
| @@ -207,6 +208,13 @@ class Container: | |||
| 207 | else: | 208 | else: |
| 208 | image = image.add_local_file(src, dest, copy=True) | 209 | image = image.add_local_file(src, dest, copy=True) |
| 209 | 210 | ||
| 211 | + # A repo copied in brings its `.git` along, and in a worktree that is a | ||
| 212 | + # *file* holding `gitdir: <path on the machine that copied it>`. Nix | ||
| 213 | + # believes it and goes looking for a checkout that is not there -- | ||
| 214 | + # `nix develop` and `nix build .#x` both die before evaluating | ||
| 215 | + # anything. Nothing in a container wants the git metadata, so it goes. | ||
| 216 | + image = image.run_commands(f"rm -rf {self.workdir}/.git") | ||
| 217 | + | ||
| 210 | if commands := build.get("commands", []): | 218 | if commands := build.get("commands", []): |
| 211 | image = image.run_commands(*commands) | 219 | image = image.run_commands(*commands) |
| 212 | 220 | ||