{"record":{"id":"dc5c715b7fa64db2","repo":"charmbracelet/crush","slug":"failed-to-create-stdout-log-file-v","errorCode":null,"errorMessage":"failed to create stdout log file: %v","messagePattern":"failed to create stdout log file: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/root.go","lineNumber":882,"sourceCode":"\t}\n\n\tcmdArgs := []string{\"server\"}\n\tif clientHost != server.DefaultHost() {\n\t\tcmdArgs = append(cmdArgs, \"--host\", clientHost)\n\t}\n\n\t// Use context.Background() so the parent's context cancellation does not\n\t// kill the spawned server. detachProcess (Setsid on !windows,\n\t// DETACHED_PROCESS on windows) is what truly detaches the child from\n\t// this process's lifetime.\n\tc := exec.CommandContext(context.Background(), exe, cmdArgs...)\n\tstdoutPath := filepath.Join(chDir, \"stdout.log\")\n\tstderrPath := filepath.Join(chDir, \"stderr.log\")\n\tdetachProcess(c)\n\n\tstdout, err := os.Create(stdoutPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create stdout log file: %v\", err)\n\t}\n\tdefer stdout.Close()\n\tc.Stdout = stdout\n\n\tstderr, err := os.Create(stderrPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create stderr log file: %v\", err)\n\t}\n\tdefer stderr.Close()\n\tc.Stderr = stderr\n\n\tif err := c.Start(); err != nil {\n\t\treturn fmt.Errorf(\"failed to start crush server: %v\", err)\n\t}\n\n\tif err := c.Process.Release(); err != nil {\n\t\treturn fmt.Errorf(\"failed to detach crush server process: %v\", err)\n\t}","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/root.go#L864-L900","documentation":"startDetachedServer redirects the detached server process's stdout to <chDir>/stdout.log by creating that file with os.Create. If creation fails, the error is wrapped as 'failed to create stdout log file' and the spawn is aborted.","triggerScenarios":"os.Create(stdoutPath) fails: the per-host dir is unwritable, the disk is full, a directory named stdout.log exists, or security software blocks file creation in the cache dir.","commonSituations":"Read-only cache filesystem in containers; disk quota exceeded from oversized existing stdout.log files; permission drift after running as another user; logs dir managed/mounted specially.","solutions":["Check writability of the per-host server directory and fix permissions (chown/chmod) or run as the correct user.","Free disk space / clear quota if the filesystem is full; consider truncating huge old stdout.log files.","Remove any file/directory incorrectly occupying the stdout.log path.","Point the cache directory at a writable location via the appropriate env (XDG_CACHE_HOME)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"logPath := filepath.Join(chDir, \"stdout.log\")\nif info, err := os.Lstat(logPath); err == nil && info.IsDir() {\n\treturn fmt.Errorf(\"%s is a directory; remove it before starting\", logPath)\n}\nif err := checkDirWritable(chDir); err != nil {\n\treturn fmt.Errorf(\"server dir not writable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Rotate or truncate stdout.log/stderr.log before they exhaust disk quota","Keep the cache dir on a writable local filesystem","Ensure no directory occupies the log file path","Run as the user that owns the 0o700 server directory"],"tags":["filesystem","logging","process-spawn","permissions"],"backgroundTag":"log-file-creation-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}