wavetermdev/waveterm · error

error writing zsh-integration .zshrc: %v

Error message

error writing zsh-integration .zshrc: %v

What it means

InitRcFiles renders ZshStartup_Zshrc via WriteTemplateToFile into <dir>/.zshrc; failure is wrapped in this error. Missing .zshrc means the main zsh integration hooks (prompt, commands, ssh integration) never load.

Source

Thrown at pkg/util/shellutil/shellutil.go:399

	if runtime.GOOS == "windows" {
		pathSep = ";"
	} else {
		pathSep = ":"
	}
	params := map[string]string{
		"WSHBINDIR":      HardQuote(absWshBinDir),
		"WSHBINDIR_PWSH": HardQuotePowerShell(absWshBinDir),
		"PATHSEP":        pathSep,
	}

	// write files to directory
	err = utilfn.WriteTemplateToFile(filepath.Join(zshDir, ".zprofile"), ZshStartup_Zprofile, params)
	if err != nil {
		return fmt.Errorf("error writing zsh-integration .zprofile: %v", err)
	}
	err = utilfn.WriteTemplateToFile(filepath.Join(zshDir, ".zshrc"), ZshStartup_Zshrc, params)
	if err != nil {
		return fmt.Errorf("error writing zsh-integration .zshrc: %v", err)
	}
	err = utilfn.WriteTemplateToFile(filepath.Join(zshDir, ".zlogin"), ZshStartup_Zlogin, params)
	if err != nil {
		return fmt.Errorf("error writing zsh-integration .zlogin: %v", err)
	}
	err = utilfn.WriteTemplateToFile(filepath.Join(zshDir, ".zshenv"), ZshStartup_Zshenv, params)
	if err != nil {
		return fmt.Errorf("error writing zsh-integration .zshenv: %v", err)
	}
	err = utilfn.WriteTemplateToFile(filepath.Join(bashDir, ".bashrc"), BashStartup_Bashrc, params)
	if err != nil {
		return fmt.Errorf("error writing bash-integration .bashrc: %v", err)
	}
	err = os.WriteFile(filepath.Join(bashDir, "bash_preexec.sh"), []byte(BashStartup_Preexec), 0644)
	if err != nil {
		return fmt.Errorf("error writing bash-integration bash_preexec.sh: %v", err)
	}
	err = utilfn.WriteTemplateToFile(filepath.Join(fishDir, "wave.fish"), FishStartup_Wavefish, params)

View on GitHub (pinned to a4447c1563)

Solutions

  1. Check the wrapped %v error to identify the exact OS-level cause
  2. Ensure the .zshrc path is writable and not a symlink into a read-only location (or replace the symlink)
  3. Free disk space / raise quota if ENOSPC
  4. Align file ownership: chown the zsh integration directory to the user running the shell

Example fix

// before
err := shellutil.InitRcFiles(zshDir)
// after
if err := shellutil.InitRcFiles(zshDir); err != nil {
	var pathErr *os.PathError
	if errors.As(err, &pathErr) && pathErr.Path != "" {
		_ = os.Chmod(zshDir, 0o700)
	}
	return fmt.Errorf("failed to install zsh integration: %w", err)
}
Defensive patterns

Strategy: fallback

Validate before calling

rcPath := filepath.Join(zshDir, ".zshrc")
if fi, err := os.Lstat(rcPath); err == nil && fi.Mode()&os.ModeSymlink != 0 {
	// symlinked rc file; ensure target writable or remove symlink
}
err := shellutil.InitRcFiles(zshDir)

Try / catch

if err := shellutil.InitRcFiles(zshDir); err != nil {
	if strings.Contains(err.Error(), ".zshrc") {
		return fmt.Errorf("cannot write zsh integration .zshrc into %s: %w", zshDir, err)
	}
	return err
}

Prevention

When it happens

Trigger: InitRcFiles failing to write .zshrc after .zprofile succeeded — permissions changed mid-sequence, an existing .zshrc owned by another user/open, disk filling up between writes, or template execution error in ZshStartup_Zshrc params.

Common situations: User-owned dotfile directories where the app (running as another user) cannot overwrite; immutable or symlinked .zshrc pointing to a read-only target; SELinux/AppArmor denials on writing to HOME; quota exhaustion.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/c0d5513eb1f6ec92. Report an issue: GitHub.