wavetermdev/waveterm · error

error writing zsh-integration .zshenv: %v

Error message

error writing zsh-integration .zshenv: %v

What it means

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.

Source

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

		"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)
	if err != nil {
		return fmt.Errorf("error writing fish-integration wave.fish: %v", err)
	}
	err = utilfn.WriteTemplateToFile(filepath.Join(pwshDir, "wavepwsh.ps1"), PwshStartup_wavepwsh, params)
	if err != nil {
		return fmt.Errorf("error writing pwsh-integration wavepwsh.ps1: %v", err)
	}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Fix ownership/permissions of the wave data dir so the current user can write (chown -R $USER / chmod u+w).
  2. Verify the zsh-integrations directory exists and is writable; delete and let it be recreated if corrupt.
  3. Check free disk space / quota on the volume hosting the wave data dir.
  4. Inspect the wrapped underlying error to target the exact cause (EACCES/ENOSPC/ENOENT).
Defensive patterns

Strategy: validation

Validate before calling

// ensure .zshenv destination is writable before init
zshenvPath := filepath.Join(zshDir, ".zshenv")
if fi, err := os.Stat(zshenvPath); err == nil && fi.Mode().Perm()&0200 == 0 {
	os.Chmod(zshenvPath, 0644)
}
probe := filepath.Join(zshDir, ".write-probe")
if err := os.WriteFile(probe, nil, 0644); err != nil { return err }
os.Remove(probe)

Try / catch

if err := shellutil.InitRcFiles(waveDataHome, binDir); err != nil {
	var pathErr *os.PathError
	if errors.As(err, &pathErr) && errors.Is(pathErr, fs.ErrPermission) {
		return fmt.Errorf("fix permissions on %s: %w", pathErr.Path, err)
	}
	return err
}

Prevention

When it happens

Trigger: InitRcFiles called (via initCustomShellStartupFilesInternal or InstallRcFiles) and writing <zshDir>/.zshenv fails due to permissions, missing directory, full disk, or template render error.

Common situations: Read-only home directory (e.g. container with ro volume), quota exceeded, root-owned integration dir, disk-full states on CI runners.

Understand the failure class

Background: "Permission denied" / "Failed to write" file errors: why a library can't write its files to disk (EACCES, EPERM, ENOSPC) and how to fix them — this error's family across 43 libraries.

Related errors


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