# gc --tool-images: also the current tool images no VM's state lists, on every # backend and C library, or only the named tools', however new; never one a # VM's state lists (a stopped VM's, or one deleted outside devvm), nor any # while a VM is being made. Never a VM. env SHARE=$XDG_DATA_HOME/devvm/tools # Names go only with --tool-images, and only shared tools' names. ! exec devvm gc --force node stderr '^devvm: gc_names_need_tools tool=node$' ! exec devvm gc --force --tool-images nope stderr '^devvm: unknown_tool tool=nope ' # node (node, pnpm, bun), claude and codex, all current, built for a VM # that's gone since. A VM deleted outside devvm still lists claude in its # state; node's three are old, and codex was built just now. project tl exec devvm --tools node --agents claude,codex --network open --no-git-protect exec devvm rm --force --no-export mkdir $VMS/12345612345612 exec sh -c 'printf "{\"version\": 1, \"id\": \"x\", \"name\": \"devvm-gone-12345612345612\", \"image\": \"base\", \"dir\": \"/p\", \"backend\": \"lima\", \"tools\": {\"names\": [\"claude\"], \"made\": {\"files\": [\"%s\"]}}}\n" "$(cd "$SHARE" && ls claude-*.erofs)" > "$VMS/12345612345612/vm.json"' json_set $SHARE/node-*.erofs.json built=2020-01-01T00:00:00Z json_set $SHARE/pnpm-*.erofs.json built=2020-01-01T00:00:00Z json_set $SHARE/bun-*.erofs.json built=2020-01-01T00:00:00Z json_set $SHARE/claude-*.erofs.json built=2020-01-01T00:00:00Z # Plain gc keeps every current one. exec devvm gc --force stdout '^==> nothing_to_clean$' # --tool-images claude: claude is a VM's, so nothing. exec devvm gc --force --tool-images claude stdout '^==> nothing_to_clean$' # --tool-images codex: only codex, built just now. exec devvm gc --force --tool-images codex stdout '^gc_tools_no_vm count=1 size=\S+ tools=codex \S+$' stdout '^==> deleted_tools_no_vm count=1$' exec sh -c 'cd "$SHARE" && ls *.erofs' ! stdout '^codex-' stdout '^node-' # --tool-images: node's three, not claude's (a VM's). exec devvm gc --force --tool-images stdout '^gc_tools_no_vm count=3 size=\S+ tools=node \S+, pnpm \S+, bun \S+$' stdout '^==> deleted_tools_no_vm count=3$' exec sh -c 'cd "$SHARE" && ls *.erofs' ! stdout '^(node|pnpm|bun)-' stdout '^claude-' ! exists $SHARE/.lock # Nothing is left of them. exec devvm gc --force --tool-images stdout '^==> nothing_to_clean$' ! stdout 'deleted_' # A VM that gets node later builds it again. Without a terminal, gc deletes # nothing unless --force. exec devvm --tools node --agents none --network open --no-git-protect exec devvm rm --force --no-export ! exec devvm gc --tool-images node stderr '^devvm: no_input answer=--force$' exec sh -c 'cd "$SHARE" && ls *.erofs' stdout '^node-' # While a VM is being made (its start hangs), --tool-images keeps every # current one no VM has, saying so; once its devvm is killed, nothing holds # the lock. project making git exec sh -c ': > "$STUB_DIR/start-hangs"' ! exec devvm --network open &u& wait_file $STUB_DIR/hanging exec devvm gc --force --tool-images stdout '^==> gc_tools_making count=3 tools=node \S+, pnpm \S+, bun \S+$' ! stdout 'gc_tools_no_vm|deleted_|nothing_to_clean' exec sh -c 'cd "$SHARE" && ls *.erofs' stdout '^node-' kill -KILL u wait u rm $STUB_DIR/start-hangs rm $STUB_DIR/hanging # Then --tool-images deletes node's three, but never claude (a VM's). exec devvm gc --force --tool-images stdout '^gc_tools_no_vm count=3 size=\S+ tools=node \S+, pnpm \S+, bun \S+$' stdout '^==> deleted_tools_no_vm count=3$' ! stdout gc_tools_making exec sh -c 'cd "$SHARE" && ls *.erofs' ! stdout '^(node|pnpm|bun)-' stdout '^claude-' ! exists $SHARE/.lock # codex, no VM's, then a VM whose go is being built: gc --tool-images waits # for the build, then finds the VM still being made (its start hangs once it # runs) and keeps every current one no VM lists, go too while its VM's state # doesn't list it yet. project cx git exec devvm --tools none --agents codex --network open --no-git-protect exec devvm rm --force --no-export project waits git exec sh -c 'printf devvm-tools-build > "$STUB_DIR/shell-waits-on" && printf waits > "$STUB_DIR/start-hangs-running"' ! exec devvm --tools go --agents none --network open --no-git-protect &w& wait_file $STUB_DIR/waiting exec devvm gc --force --tool-images &g& exec sleep 0.5 rm $STUB_DIR/shell-waits-on wait_file $STUB_DIR/hanging wait g stdout '^==> gc_tools_making count=[12] tools=.*codex ' ! stdout 'gc_tools_no_vm|deleted_|nothing_to_clean' exec sh -c 'cd "$SHARE" && ls *.erofs' stdout '^codex-' stdout '^go-' kill -KILL w wait w rm $STUB_DIR/start-hangs-running