{"record":{"id":"ddf3667c10af9e34","repo":"wavetermdev/waveterm","slug":"error-writing-zsh-integration-zlogin-v","errorCode":null,"errorMessage":"error writing zsh-integration .zlogin: %v","messagePattern":"error writing zsh-integration \\.zlogin: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/shellutil/shellutil.go","lineNumber":403,"sourceCode":"\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)\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)","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/util/shellutil/shellutil.go#L385-L421","documentation":"InitRcFiles writes Wave's shell integration scripts (templated rc files) into the app-managed zsh integration directory. This error wraps any failure from utilfn.WriteTemplateToFile when writing .zlogin, typically an OS-level file write failure (permission denied, read-only filesystem, missing parent dir, disk full). Wave surfaces the underlying error with %v so the root cause is appended.","triggerScenarios":"Calling InitRcFiles (directly or via initCustomShellStartupFilesInternal / InstallRcFiles) when the destination file <waveHome>/zsh-integrations/.zlogin cannot be created or written: parent dir missing/deleted, insufficient permissions, immutable file, or template execution failure.","commonSituations":"Wave's cached config dir owned by root or another user after a sudo run; ~/.waveterm placed on a read-only or full disk; antivirus/EDR locking files on Windows; the zsh-integrations directory deleted while the app runs.","solutions":["Check permissions on the wave data dir (~/.waveterm or the configured WAVETERM_HOME) and chown/chmod so the running user can write (e.g. chmod -R u+w ~/.waveterm).","Free disk space and confirm the filesystem is writable (touch a file in the zsh-integrations dir).","Delete the stale zsh-integrations directory so InitRcFiles recreates it fresh, then retry.","Read the wrapped %v detail to identify the exact OS error (EACCES vs ENOSPC vs ENOENT) and address that specifically."],"exampleFix":"// before: rc files dir owned by root after sudo install\n$ sudo wave  # creates root-owned ~/.waveterm/zsh-integrations\n// after: run as normal user, fix ownership\n$ sudo chown -R $USER ~/.waveterm && wave","handlingStrategy":"validation","validationCode":"// before InitRcFiles\nif err := os.MkdirAll(zshDir, 0755); err != nil { return err }\nif fi, err := os.Stat(zshDir); err != nil || !fi.IsDir() { return fmt.Errorf(\"zsh dir unusable\") }\nif err := syscallaccess.CheckWritable(zshDir); err != nil { return fmt.Errorf(\"zsh dir not writable: %w\", err) }","typeGuard":null,"tryCatchPattern":"if err := shellutil.InitRcFiles(waveDataHome, binDir); err != nil {\n\tif strings.Contains(err.Error(), \"zsh-integration .zlogin\") {\n\t\tlog.Printf(\"recoverable rc write failure, retrying after dir reset: %v\", err)\n\t\tos.RemoveAll(zshDir)\n\t\terr = shellutil.InitRcFiles(waveDataHome, binDir)\n\t}\n\treturn err\n}","preventionTips":["Never run the app with sudo, which leaves root-owned files in the wave data dir.","Monitor free disk space on the volume hosting the wave data dir.","Exclude the wave data dir from antivirus/sync tools that lock files.","Pre-create integration dirs with CacheEnsureDir and verify writability at startup."],"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-08T05:18:18.240Z"}