lima-vm/lima · error

stdout=%#q, stderr=%#q: %w

Error message

stdout=%#q, stderr=%#q: %w

What it means

When ssh.forwardAgent is enabled on macOS-style guests, the hostagent runs a small shell script inside the guest via ssh.ExecuteScript to symlink $SSH_AUTH_SOCK to /run/host-services/ssh-auth.sock. If the script fails, the captured stdout/stderr and the underlying error are wrapped into this error and appended to startup errors.

Source

Thrown at pkg/hostagent/hostagent.go:623

	// In the next boot, Lima will not mount OS installer ISO file to prevent unexpected re-installation.
	if *a.instConfig.OS == limatype.WINDOWS {
		if _, err := os.Create(filepath.Join(a.instDir, filenames.WinDoneInstallation)); err != nil {
			errs = append(errs, errors.New("failed to create a windows installation marker"))
		}
	}

	if *a.instConfig.SSH.ForwardAgent {
		if *a.instConfig.Plain {
			logrus.Warn("Running in plain mode. Ignoring ssh.forwardAgent")
		} else {
			faScript := `#!/bin/bash
set -eux -o pipefail
ln -sf "${SSH_AUTH_SOCK}" /run/host-services/ssh-auth.sock`
			faDesc := "linking ssh auth socket to static location /run/host-services/ssh-auth.sock"
			stdout, stderr, err := ssh.ExecuteScript(a.instSSHAddress, a.sshLocalPort, a.sshConfig, faScript, faDesc)
			logrus.Debugf("stdout=%#q, stderr=%#q, err=%v", stdout, stderr, err)
			if err != nil {
				errs = append(errs, fmt.Errorf("stdout=%#q, stderr=%#q: %w", stdout, stderr, err))
			}
		}
	}
	if *a.instConfig.MountType == limatype.REVSSHFS && !*a.instConfig.Plain {
		mounts, err := a.setupMounts(ctx)
		if err != nil {
			errs = append(errs, err)
		}
		a.cleanUp(func() error {
			var unmountErrs []error
			for _, m := range mounts {
				if unmountErr := m.close(); unmountErr != nil {
					unmountErrs = append(unmountErrs, unmountErr)
				}
			}
			return errors.Join(unmountErrs...)
		})
	}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Read the stdout/stderr in the error to see why the symlink script failed inside the guest
  2. Retry 'limactl start' after the VM has fully booted — early-boot timing is a common cause
  3. Verify SSH access works: limactl shell <instance> should connect without errors
  4. Disable ssh.forwardAgent if you don't need agent forwarding, or fix guest permissions for /run/host-services

Example fix

// before (lima.yaml)
ssh:
  forwardAgent: true   # failing in guest
// after
ssh:
  forwardAgent: false
Defensive patterns

Strategy: retry

Validate before calling

// verify SSH connectivity before running forward-agent setup
if err := ssh.Validate(instSSHAddress, sshLocalPort, sshConfig); err != nil {
	return fmt.Errorf("guest SSH not ready: %w", err)
}

Try / catch

if strings.Contains(err.Error(), "stdout=") && strings.Contains(err.Error(), "ln -sf") {
	// guest may not be fully booted; wait and retry once
	time.Sleep(10 * time.Second)
	return startHostAgentRoutines(ctx, out)
}

Prevention

When it happens

Trigger: startHostAgentRoutines with SSH.ForwardAgent true where the guest script fails: SSH connection to the guest fails, the script exits non-zero (e.g. permission denied writing /run/host-services, /run not writable, shell unavailable), or the guest is not yet ready.

Common situations: Guest not fully booted when the script runs; macOS guest where /run/host-services path can't be created without root; SSH key/auth problems; network not yet up inside the VM.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/5a9ac395eeb17fe8. Report an issue: GitHub.