{"record":{"id":"bb2ba19241da125e","repo":"wavetermdev/waveterm","slug":"error-writing-zsh-integration-zprofile-v","errorCode":null,"errorMessage":"error writing zsh-integration .zprofile: %v","messagePattern":"error writing zsh-integration \\.zprofile: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/shellutil/shellutil.go","lineNumber":395,"sourceCode":"\t\treturn err\n\t}\n\n\tvar pathSep string\n\tif runtime.GOOS == \"windows\" {\n\t\tpathSep = \";\"\n\t} else {\n\t\tpathSep = \":\"\n\t}\n\tparams := map[string]string{\n\t\t\"WSHBINDIR\":      HardQuote(absWshBinDir),\n\t\t\"WSHBINDIR_PWSH\": HardQuotePowerShell(absWshBinDir),\n\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)","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/util/shellutil/shellutil.go#L377-L413","documentation":"InitRcFiles renders the zsh integration template ZshStartup_Zprofile and writes it to <dir>/.zprofile via WriteTemplateToFile; any write/template failure is wrapped in this error. Without .zprofile the zsh integration scripts are incomplete and shell integration will not fully activate.","triggerScenarios":"InitRcFiles failing to write .zprofile — directory doesn't exist or is not writable, disk full, read-only filesystem, permissions denied on the target path, or template execution error in ZshStartup_Zprofile params.","commonSituations":"Installing rc files into a HOME with restrictive permissions; read-only container images; ~/.zshdir path created with wrong ownership after running as different users; NFS-mounted homes with quota exceeded.","solutions":["Ensure the target zsh integration directory exists and is writable by the current user (mkdir -p, chown)","Check disk space and quota on the volume holding the directory","Look at the wrapped %v error to distinguish permission vs template failures","Run as the correct user — files written by root into a user HOME cause later EACCES"],"exampleFix":"// before\nerr := shellutil.InitRcFiles(zshDir)\n// after\nif err := os.MkdirAll(zshDir, 0o700); err != nil {\n\treturn err\n}\nif err := shellutil.InitRcFiles(zshDir); err != nil {\n\treturn fmt.Errorf(\"rc file install failed (check perms/space on %s): %w\", zshDir, err)\n}","handlingStrategy":"validation","validationCode":"if err := os.MkdirAll(zshDir, 0o700); err != nil {\n\treturn err\n}\nif fi, err := os.Stat(zshDir); err != nil || !fi.IsDir() {\n\treturn fmt.Errorf(\"zsh dir %s not writable\", zshDir)\n}\nerr := shellutil.InitRcFiles(zshDir)","typeGuard":null,"tryCatchPattern":"if err := shellutil.InitRcFiles(zshDir); err != nil {\n\tif strings.Contains(err.Error(), \".zprofile\") {\n\t\tvar pe *os.PathError\n\t\tif errors.As(err, &pe) {\n\t\t\tlog.Printf(\"write failed on %s: %v\", pe.Path, pe.Err)\n\t\t}\n\t}\n\treturn err\n}","preventionTips":["Create the integration directory with correct perms before installing rc files","Ensure the process runs as the user who owns HOME","Check disk space/quota before writing rc files","Unwrap the wrapped error to distinguish EACCES vs ENOSPC vs template errors"],"tags":["zsh","file-write","shell-integration"],"backgroundTag":"rc-file-write-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}