wavetermdev/waveterm · error

error writing zsh-integration .zprofile

Error message

error writing zsh-integration .zprofile: %v

What it means

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.

Solutions

  1. Ensure the target zsh integration directory exists and is writable by the current user (mkdir -p, chown)
  2. Check disk space and quota on the volume holding the directory
  3. Look at the wrapped %v error to distinguish permission vs template failures
  4. Run as the correct user — files written by root into a user HOME cause later EACCES

Example fix

// before
err := shellutil.InitRcFiles(zshDir)
// after
if err := os.MkdirAll(zshDir, 0o700); err != nil {
	return err
}
if err := shellutil.InitRcFiles(zshDir); err != nil {
	return fmt.Errorf("rc file install failed (check perms/space on %s): %w", zshDir, err)
}
Defensive patterns

Strategy: validation

Validate before calling

if err := os.MkdirAll(zshDir, 0o700); err != nil {
	return err
}
if fi, err := os.Stat(zshDir); err != nil || !fi.IsDir() {
	return fmt.Errorf("zsh dir %s not writable", zshDir)
}
err := shellutil.InitRcFiles(zshDir)

Try / catch

if err := shellutil.InitRcFiles(zshDir); err != nil {
	if strings.Contains(err.Error(), ".zprofile") {
		var pe *os.PathError
		if errors.As(err, &pe) {
			log.Printf("write failed on %s: %v", pe.Path, pe.Err)
		}
	}
	return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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

Appendix: source

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

		return err
	}

	var pathSep string
	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)

View on GitHub (pinned to a4447c1563)