{"record":{"id":"5a9ac395eeb17fe8","repo":"lima-vm/lima","slug":"stdout-q-stderr-q-w","errorCode":null,"errorMessage":"stdout=%#q, stderr=%#q: %w","messagePattern":"stdout=%#q, stderr=%#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hostagent/hostagent.go","lineNumber":623,"sourceCode":"\t// In the next boot, Lima will not mount OS installer ISO file to prevent unexpected re-installation.\n\tif *a.instConfig.OS == limatype.WINDOWS {\n\t\tif _, err := os.Create(filepath.Join(a.instDir, filenames.WinDoneInstallation)); err != nil {\n\t\t\terrs = append(errs, errors.New(\"failed to create a windows installation marker\"))\n\t\t}\n\t}\n\n\tif *a.instConfig.SSH.ForwardAgent {\n\t\tif *a.instConfig.Plain {\n\t\t\tlogrus.Warn(\"Running in plain mode. Ignoring ssh.forwardAgent\")\n\t\t} else {\n\t\t\tfaScript := `#!/bin/bash\nset -eux -o pipefail\nln -sf \"${SSH_AUTH_SOCK}\" /run/host-services/ssh-auth.sock`\n\t\t\tfaDesc := \"linking ssh auth socket to static location /run/host-services/ssh-auth.sock\"\n\t\t\tstdout, stderr, err := ssh.ExecuteScript(a.instSSHAddress, a.sshLocalPort, a.sshConfig, faScript, faDesc)\n\t\t\tlogrus.Debugf(\"stdout=%#q, stderr=%#q, err=%v\", stdout, stderr, err)\n\t\t\tif err != nil {\n\t\t\t\terrs = append(errs, fmt.Errorf(\"stdout=%#q, stderr=%#q: %w\", stdout, stderr, err))\n\t\t\t}\n\t\t}\n\t}\n\tif *a.instConfig.MountType == limatype.REVSSHFS && !*a.instConfig.Plain {\n\t\tmounts, err := a.setupMounts(ctx)\n\t\tif err != nil {\n\t\t\terrs = append(errs, err)\n\t\t}\n\t\ta.cleanUp(func() error {\n\t\t\tvar unmountErrs []error\n\t\t\tfor _, m := range mounts {\n\t\t\t\tif unmountErr := m.close(); unmountErr != nil {\n\t\t\t\t\tunmountErrs = append(unmountErrs, unmountErr)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn errors.Join(unmountErrs...)\n\t\t})\n\t}","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/hostagent/hostagent.go#L605-L641","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the stdout/stderr in the error to see why the symlink script failed inside the guest","Retry 'limactl start' after the VM has fully booted — early-boot timing is a common cause","Verify SSH access works: limactl shell <instance> should connect without errors","Disable ssh.forwardAgent if you don't need agent forwarding, or fix guest permissions for /run/host-services"],"exampleFix":"// before (lima.yaml)\nssh:\n  forwardAgent: true   # failing in guest\n// after\nssh:\n  forwardAgent: false","handlingStrategy":"retry","validationCode":"// verify SSH connectivity before running forward-agent setup\nif err := ssh.Validate(instSSHAddress, sshLocalPort, sshConfig); err != nil {\n\treturn fmt.Errorf(\"guest SSH not ready: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"stdout=\") && strings.Contains(err.Error(), \"ln -sf\") {\n\t// guest may not be fully booted; wait and retry once\n\ttime.Sleep(10 * time.Second)\n\treturn startHostAgentRoutines(ctx, out)\n}","preventionTips":["Wait for guest boot readiness before agent-forwarding setup","Test 'limactl shell <instance>' connectivity before scripted SSH runs","Confirm the guest can write /run/host-services (or run the symlink with adequate privileges)","Disable ssh.forwardAgent if agent forwarding is not required"],"tags":["ssh","forward-agent","guest","script"],"backgroundTag":"ssh-script-execution-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}