If the system shuts down before limactl start --foreground finishes cleanup (signal handler in hostagent.go), stale ha.pid and ha.sock files remain in the instance directory. On the next boot, limactl start tries to connect to the stale ha.sock, gets connection refused, and exits with a fatal error instead of cleaning up and starting fresh.
The hostagent command already has defer os.RemoveAll(pidfile) and signal handling via signalCh, but macOS may kill the process before cleanup completes during a fast shutdown. limactl start could check whether the PID in ha.pid is actually running before attempting to connect to ha.sock, and clean up stale files if it's not.
This is one of several issues that make Lima unusable for unattended auto-start via LaunchDaemon. See also #2252.
Environment: macOS 15.7.7, Lima 2.1.x (fork), LaunchDaemon with RunAtLoad.
If the system shuts down before
limactl start --foregroundfinishes cleanup (signal handler inhostagent.go), staleha.pidandha.sockfiles remain in the instance directory. On the next boot,limactl starttries to connect to the staleha.sock, gets connection refused, and exits with a fatal error instead of cleaning up and starting fresh.The hostagent command already has
defer os.RemoveAll(pidfile)and signal handling viasignalCh, but macOS may kill the process before cleanup completes during a fast shutdown.limactl startcould check whether the PID inha.pidis actually running before attempting to connect toha.sock, and clean up stale files if it's not.This is one of several issues that make Lima unusable for unattended auto-start via LaunchDaemon. See also #2252.
Environment: macOS 15.7.7, Lima 2.1.x (fork), LaunchDaemon with
RunAtLoad.