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

51 lines
1.8 KiB
Plaintext

# The host terminal's COLORTERM: a shell in the VM and an agent's login
# get it when it's truecolor or 24bit, set by the command devvm runs in
# the VM (limactl shell's own SendEnv never reaches it); any other value,
# or none, sets nothing, and the shell is limactl shell's own.
# A new VM's first shell.
project web
env COLORTERM=truecolor
exec devvm --network open --no-git-protect --agents codex
stub_calls
stdout '^limactl shell --start=false --workdir /\S*/web devvm-web-[0-9a-f]{14} sh -c export COLORTERM=''truecolor'' && exec "\$SHELL" --login\n\z'
# A shell in the running VM.
env COLORTERM=24bit
stub_reset
exec devvm
stub_calls
stdout '^limactl shell --start=false --workdir /\S*/web devvm-web-[0-9a-f]{14} sh -c export COLORTERM=''24bit'' && exec "\$SHELL" --login\n\z'
# Any other value, or none: nothing.
env COLORTERM='truecolor'';touch /tmp/p'
stub_reset
exec devvm
stub_calls
stdout '^limactl shell --start=false --workdir /\S*/web devvm-web-[0-9a-f]{14}\n\z'
env COLORTERM=256color
stub_reset
exec devvm
stub_calls
stdout '^limactl shell --start=false --workdir /\S*/web devvm-web-[0-9a-f]{14}\n\z'
env COLORTERM=
stub_reset
exec devvm
stub_calls
stdout '^limactl shell --start=false --workdir /\S*/web devvm-web-[0-9a-f]{14}\n\z'
# An agent's login, with truecolor, then with another value. (The stub
# saves no login, so devvm says so.)
env COLORTERM=truecolor
stub_reset
! exec devvm agent login codex --device-code
stderr '^devvm: agent_login_not_saved agent=codex vm=devvm-web-[0-9a-f]{14}$'
stub_calls
stdout ' sh -c cd ''/'' && export COLORTERM=''truecolor'' && exec ''bash'' ''-lc'' .* ''login'' ''--device-auth''$'
env COLORTERM=xterm
stub_reset
! exec devvm agent login codex --device-code
stub_calls
stdout ' sh -c cd ''/'' && exec ''bash'' ''-lc'' .* ''login'' ''--device-auth''$'
! stdout COLORTERM