{"record":{"id":"1ddcad8b7df60c5f","repo":"jesseduffield/lazygit","slug":"createpseudoconsole-w","errorCode":null,"errorMessage":"CreatePseudoConsole: %w","messagePattern":"CreatePseudoConsole: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/oscommands/pty_windows.go","lineNumber":320,"sourceCode":"\t// direct child of this process. The teardown in Close needs a handle to\n\t// that conhost (see there), but Windows offers no way to obtain one\n\t// from the HPCON, so identify it by diffing our conhost children around\n\t// the call. Open a real handle right away so that pid reuse can't later\n\t// misdirect the teardown's reap. If identification fails, the handle\n\t// stays 0 and the teardown skips the reap.\n\tvar hpc, conhost windows.Handle\n\tsize := clampPtySize(cols, rows)\n\tconhostScanMu.Lock()\n\tconhostsBefore := conhostChildren()\n\terr = windows.CreatePseudoConsole(size, inRead, outWrite, 0, &hpc)\n\tif err == nil {\n\t\tconhost = openNewConhostChild(conhostsBefore)\n\t}\n\tconhostScanMu.Unlock()\n\tif err != nil {\n\t\t_ = windows.CloseHandle(inRead)\n\t\t_ = windows.CloseHandle(outWrite)\n\t\treturn StartedPty{}, fmt.Errorf(\"CreatePseudoConsole: %w\", err)\n\t}\n\t_ = windows.CloseHandle(inRead)\n\t_ = windows.CloseHandle(outWrite)\n\tdefer func() {\n\t\tif err != nil {\n\t\t\twindows.ClosePseudoConsole(hpc)\n\t\t\tif conhost != 0 {\n\t\t\t\t_ = windows.CloseHandle(conhost)\n\t\t\t}\n\t\t}\n\t}()\n\n\t// The child goes into a job object so that the teardown in Close can\n\t// terminate the whole process tree. KILL_ON_JOB_CLOSE makes the OS do\n\t// that when the last handle to the job is closed, which doubles as a\n\t// safety net: if lazygit exits without running the teardown, the handle\n\t// is closed for it and the tree is reaped.\n\tjob, err := windows.CreateJobObject(nil, nil)","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/commands/oscommands/pty_windows.go#L302-L338","documentation":"StartPty calls CreatePseudoConsole (the ConPTY API, Windows 10 1809+) to set up the pseudoconsole using the two pipe ends. On failure it closes the child-side pipe handles and returns this wrapped error. Typical causes: unsupported/old Windows build, conhost.exe problems, or exhausted console sessions.","triggerScenarios":"CreatePseudoConsole returning an error: running on Windows older than 10 1809 (API missing), conhost.exe missing/blocked, too many active ConPTY sessions, or corrupted console driver state.","commonSituations":"Old Windows Server or LTSB/LTSC builds predating ConPTY; locked-down machines where conhost is disallowed; terminal-driver issues after RDP/session switches.","solutions":["Verify Windows 10 1809+ / Server 2019+ (`winver`); on older builds PTY-backed features can't work.","Ensure conhost.exe exists and isn't blocked by policy/AV; try 'conhost.exe' from a terminal.","Sign out/in (or reboot) to reset console session state if it worked before.","Update lazygit — the integration layer here keeps changing with Windows releases."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Feature-detect ConPTY before attempting StartPty:\nfunc conptyAvailable() bool {\n    v := windows.RtlGetVersion() // or syscall GetVersionEx equivalent\n    return v.Major > 10 || (v.Major == 10 && v.Build >= 17763) // 1809\n}","typeGuard":null,"tryCatchPattern":"sp, err := oscommands.StartPty(cmd, cols, rows)\nif err != nil {\n    if strings.Contains(err.Error(), \"CreatePseudoConsole\") {\n        // pre-1809 Windows or conhost unavailable: run without a pty\n        return runWithoutPty(cmd)\n    }\n    return err\n}","preventionTips":["Require Windows 10 1809+ for PTY features; gate on OS build at startup.","Ensure conhost.exe is present and not blocked by policy/AV on managed machines.","Provide a non-PTY execution fallback so older Windows still works."],"tags":["windows","pty","conpty","syscall","compatibility"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}