Files
w3cjandClaude Opus 5.5 e4b44b5994 fix(lima): limactl shell never starts a stopped VM past devvm's checks
In a terminal, limactl shell of a stopped VM asks whether to start it, yes by default (Lima 2.3.0, reproduced under a pty), and that start is Lima's own: no proxy or sandbox-exec profile (no QEMU wrapper on Linux), no pins, and no folderChanged, so the project folder's mount, by path on Linux's 9p, follows a link put at the path or makes a folder that's gone again. devvm opens a shell (Shell) and runs an agent's login (Exec) on the terminal after bringUp, so a guest that powered itself off between the two got that question. This is the start path the self-check's restart was suspected of: that restart goes through startOnce, but limactl shell didn't.

The limactl builder, which every limactl command of devvm's goes through, now gives limactl shell --start=false, which Lima has had since 2.0.0-rc.0 (devvm's oldest is 2.2): a stopped VM's shell or command fails at once ("instance is stopped"), without asking, and devvm's next launch starts it with every check. devvm limactl, which passes its arguments on as given, is unchanged.

TestShellNeverStarts checks Exec's, Shell's and the builder's limactl shell, and fails without the change; the lima package's and the CLI scripts' expected limactl shell calls name the flag, their negative patterns too, so none turns vacuous. Docs: How it works' Lima page's A stopped VM's shell; the changelog's Security hardening gets the line, its summary widened to cover both of its lines, and the release page its section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 07:43:53 -07:00

106 lines
4.1 KiB
Plaintext

# devvm layer rm LAYER...: the folder's VM made again from its image
# without those layers, the rest in their order, after asking, keeping
# its settings and its home folder: devvm layer add's remake. A layer it
# lacks is said, and one of the user's whose script is gone can be taken
# out. devvm tools rm of a layer names devvm layer rm.
env LAYERS=$XDG_CONFIG_HOME/devvm/layers
# Usage errors, before anything runs.
! exec devvm layer rm
stderr '^devvm: arg_missing args=LAYER\.\.\. command=devvm layer rm$'
! exec devvm layer rm base
stderr '^devvm: unknown_layer layer=base layers=desktop docker nix$'
! exec devvm layer rm node
stderr '^devvm: tool_not_layer tool=node$'
exec devvm __complete layer rm d
stdout '^desktop\ndocker\n'
# No VM.
project web
! exec devvm layer rm docker --force
stderr '^devvm: no_vm dir=/\S*/web$'
# A VM of docker, nix and a layer of the user's, with ports, a rule and
# files in its project folder and its home.
exec devvm layer new foo
exec devvm --network open --no-git-protect --agents claude --layers docker,nix,foo --ports 3000
vm_name WEB web
exec devvm network allow example.com
exec sh -c 'echo kept > notes && mkdir -p "$STUB_DIR/vmhome-$WEB" && echo ls > "$STUB_DIR/vmhome-$WEB/.bash_history"'
vm_state $WEB_dir/vm.json
stdout '^image=docker\+nix\+foo$'
# devvm tools rm of a layer names devvm layer rm.
! exec devvm tools rm docker
stderr '^devvm: custom_layer_remove layer=docker vm=devvm-web-[0-9a-f]{14}$'
# A layer it lacks is said, and nothing runs; a name that isn't a layer
# is refused.
stub_reset
exec devvm layer rm desktop --force
stdout '^==> lacks_layers layers=desktop vm=devvm-web-[0-9a-f]{14}$'
! exec devvm layer rm dockr --force
stderr '^devvm: unknown_layer_like layer=dockr like=docker$'
stub_calls
! stdout 'limactl (stop|rename|clone|delete)'
# Without a terminal it refuses unless --force; in one it asks, and no
# keeps the VM.
! exec devvm layer rm nix
stderr '^devvm: no_input answer=--force$'
ttyin -stdin $WORK/no.txt
exec devvm layer rm nix
stderr '^remake_confirm image=docker\+foo vm=devvm-web-[0-9a-f]{14} \[y/N\] '
stdout '==> kept vm=devvm-web-[0-9a-f]{14}$'
stub_calls
! stdout 'limactl (stop|rename|clone|delete)'
# --force: built, exported, home saved, stopped and set aside, made again
# and started, home put back, the old machine deleted, then a shell.
stub_reset
exec devvm layer rm nix --force
stdout '==> exported '
stdout '==> saving_home vm=devvm-web-[0-9a-f]{14}$'
stdout '==> creating_from image=docker\+foo vm=devvm-web-[0-9a-f]{14}$'
stdout '==> remade image=docker\+foo vm=devvm-web-[0-9a-f]{14}$'
stub_calls
stdout 'limactl stop devvm-web-[0-9a-f]{14}\n(.*\n)*limactl rename --tty=false devvm-web-[0-9a-f]{14} devvm-[0-9a-f]{14}-old\n(.*\n)*limactl clone --tty=false devvm-img-[0-9a-f]+ devvm-web-[0-9a-f]{14} .*\n(.*\n)*limactl start --tty=false devvm-web-[0-9a-f]{14}\n(.*\n)*.*tar -xzf - --skip-old-files.*\n(.*\n)*limactl delete -f devvm-[0-9a-f]{14}-old\n(.*\n)*limactl shell --start=false --workdir /\S*/web devvm-web-[0-9a-f]{14}\n'
vm_state $WEB_dir/vm.json
stdout '^image=docker\+foo$'
stdout '^ports.forward=3000$'
stdout '^tools.names=claude$'
! stdout '^remake'
grep '^example\.com$' $WEB_dir/policy
grep '^kept$' notes
# The user's layer's script gone: the VM can't be updated or have a
# layer added, and devvm layer rm takes it out.
rm $LAYERS/foo.sh
! exec devvm layer add nix --force
stderr '^devvm: unknown_layer layer=foo '
stub_reset
exec devvm layer rm foo --force --no-export --clean-home
! stdout exported
! stdout saving_home
stdout '==> remade image=docker vm=devvm-web-[0-9a-f]{14}$'
vm_state $WEB_dir/vm.json
stdout '^image=docker$'
# Every layer out: base.
exec devvm layer rm docker --force --no-export
vm_state $WEB_dir/vm.json
stdout '^image=base$'
# Refused: a --clone VM, and a parent folder's VM without a terminal.
json_set $WEB_dir/vm.json 'clone:={"on":true}'
! exec devvm layer rm docker --force
stderr '^devvm: remake_clone vm=devvm-web-[0-9a-f]{14}$'
json_set $WEB_dir/vm.json 'clone:={}'
mkdir sub
cd sub
! exec devvm layer rm docker --force
stderr '^devvm: remake_parent_vm command=devvm layer rm docker dir=/\S*/web vm=devvm-web-[0-9a-f]{14}$'
-- no.txt --
n