{"record":{"id":"2f1a3d11cf77f34c","repo":"wavetermdev/waveterm","slug":"error-writing-zsh-integration-zshenv-v","errorCode":null,"errorMessage":"error writing zsh-integration .zshenv: %v","messagePattern":"error writing zsh-integration \\.zshenv: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/shellutil/shellutil.go","lineNumber":407,"sourceCode":"\t\t\"PATHSEP\":        pathSep,\n\t}\n\n\t// write files to directory\n\terr = utilfn.WriteTemplateToFile(filepath.Join(zshDir, \".zprofile\"), ZshStartup_Zprofile, params)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing zsh-integration .zprofile: %v\", err)\n\t}\n\terr = utilfn.WriteTemplateToFile(filepath.Join(zshDir, \".zshrc\"), ZshStartup_Zshrc, params)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing zsh-integration .zshrc: %v\", err)\n\t}\n\terr = utilfn.WriteTemplateToFile(filepath.Join(zshDir, \".zlogin\"), ZshStartup_Zlogin, params)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing zsh-integration .zlogin: %v\", err)\n\t}\n\terr = utilfn.WriteTemplateToFile(filepath.Join(zshDir, \".zshenv\"), ZshStartup_Zshenv, params)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing zsh-integration .zshenv: %v\", err)\n\t}\n\terr = utilfn.WriteTemplateToFile(filepath.Join(bashDir, \".bashrc\"), BashStartup_Bashrc, params)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing bash-integration .bashrc: %v\", err)\n\t}\n\terr = os.WriteFile(filepath.Join(bashDir, \"bash_preexec.sh\"), []byte(BashStartup_Preexec), 0644)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing bash-integration bash_preexec.sh: %v\", err)\n\t}\n\terr = utilfn.WriteTemplateToFile(filepath.Join(fishDir, \"wave.fish\"), FishStartup_Wavefish, params)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing fish-integration wave.fish: %v\", err)\n\t}\n\terr = utilfn.WriteTemplateToFile(filepath.Join(pwshDir, \"wavepwsh.ps1\"), PwshStartup_wavepwsh, params)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing pwsh-integration wavepwsh.ps1: %v\", err)\n\t}\n","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/util/shellutil/shellutil.go#L389-L425","documentation":"Same family as the .zlogin error: InitRcFiles fails while templating .zshenv into the zsh-integrations directory. The wrapped error from utilfn.WriteTemplateToFile (or os-level write) is included via %v. Without .zshenv, Wave's zsh integration (wsh on PATH etc.) will not initialize in non-interactive shells.","triggerScenarios":"InitRcFiles called (via initCustomShellStartupFilesInternal or InstallRcFiles) and writing <zshDir>/.zshenv fails due to permissions, missing directory, full disk, or template render error.","commonSituations":"Read-only home directory (e.g. container with ro volume), quota exceeded, root-owned integration dir, disk-full states on CI runners.","solutions":["Fix ownership/permissions of the wave data dir so the current user can write (chown -R $USER / chmod u+w).","Verify the zsh-integrations directory exists and is writable; delete and let it be recreated if corrupt.","Check free disk space / quota on the volume hosting the wave data dir.","Inspect the wrapped underlying error to target the exact cause (EACCES/ENOSPC/ENOENT)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure .zshenv destination is writable before init\nzshenvPath := filepath.Join(zshDir, \".zshenv\")\nif fi, err := os.Stat(zshenvPath); err == nil && fi.Mode().Perm()&0200 == 0 {\n\tos.Chmod(zshenvPath, 0644)\n}\nprobe := filepath.Join(zshDir, \".write-probe\")\nif err := os.WriteFile(probe, nil, 0644); err != nil { return err }\nos.Remove(probe)","typeGuard":null,"tryCatchPattern":"if err := shellutil.InitRcFiles(waveDataHome, binDir); err != nil {\n\tvar pathErr *os.PathError\n\tif errors.As(err, &pathErr) && errors.Is(pathErr, fs.ErrPermission) {\n\t\treturn fmt.Errorf(\"fix permissions on %s: %w\", pathErr.Path, err)\n\t}\n\treturn err\n}","preventionTips":["Check quota/disk space before first-run initialization.","Keep the wave data dir on a local read-write filesystem, not a ro container layer or NFS ro mount.","After permission fixes, delete the stale zsh-integrations dir so files are regenerated cleanly.","Surface the wrapped error (%v) to logs to distinguish EACCES vs ENOSPC quickly."],"tags":["filesystem","shell-integration","zsh","file-write"],"backgroundTag":"file-write-permission-denied","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}