wavetermdev/waveterm · error
error writing pwsh-integration wavepwsh.ps1: %v
Error message
error writing pwsh-integration wavepwsh.ps1: %v
What it means
InitRcFiles wraps a failure from utilfn.WriteTemplateToFile when writing wavepwsh.ps1 into the pwsh-integrations directory. This is the last rc file in the sequence; failure means the PowerShell integration script could not be materialized, usually due to filesystem permissions or locks.
Source
Thrown at pkg/util/shellutil/shellutil.go:423
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)
}
return nil
}
func initCustomShellStartupFilesInternal() error {
log.Printf("initializing wsh and shell startup files\n")
waveDataHome := wavebase.GetWaveDataDir()
binDir := filepath.Join(waveDataHome, WaveHomeBinDir)
err := InitRcFiles(waveDataHome, binDir)
if err != nil {
return err
}
err = wavebase.CacheEnsureDir(binDir, WaveHomeBinDir, 0755, WaveHomeBinDir)
if err != nil {
return err
}View on GitHub (pinned to a4447c1563)
Solutions
- Close open PowerShell sessions and exclude the wave data dir from AV/sync tools, then retry.
- Fix ACLs/permissions on the pwsh-integrations directory so the user can write.
- Delete wavepwsh.ps1 (or the whole pwsh-integrations dir) and rerun initialization.
- Check the wrapped %v text for the specific underlying error.
Example fix
// before: Windows Defender controlled folder access blocks write // after: add wave data dir to allowed apps list, or PS> icacls "$env:USERPROFILE\.waveterm\pwsh-integrations" /grant "$env:USERNAME:(OI)(CI)F"
Defensive patterns
Strategy: validation
Validate before calling
// PowerShell/Windows: confirm ACL allows write before init
fi, err := os.Stat(pwshDir)
if err != nil || !fi.IsDir() { os.MkdirAll(pwshDir, 0755) }
probe := filepath.Join(pwshDir, ".probe")
if err := os.WriteFile(probe, nil, 0644); err != nil {
return fmt.Errorf("pwsh-integrations not writable (check ACL/AV locks): %w", err)
}
os.Remove(probe) Try / catch
if err := shellutil.InitRcFiles(home, binDir); err != nil {
var pe *os.PathError
if errors.As(err, &pe) && runtime.GOOS == "windows" {
log.Printf("pwsh write blocked on %s: %v; retry after closing PowerShell/AV", pe.Path, pe.Err)
}
return err
} Prevention
- Keep the wave data dir out of OneDrive/Dropbox sync folders on Windows.
- Add the wave data dir to Defender controlled-folder-access allowlist.
- Close pwsh sessions that sourced wavepwsh.ps1 before upgrading.
- Recreate the pwsh-integrations dir if wavepwsh.ps1 is in a corrupt state.
When it happens
Trigger: InitRcFiles / InstallRcFiles failing to open/replace <pwshDir>/wavepwsh.ps1: ACL denial on Windows, file locked by an open PowerShell session or AV scanner, missing dir, or template render error.
Common situations: Windows: OneDrive/Dropbox-synced wave dir locking files; controlled-folder-access blocking writes; POSIX: ro-mounted home; PowerShell sessions holding the .ps1 open.
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
- error writing zsh-integration .zlogin: %v
- error writing zsh-integration .zshenv: %v
- error writing bash-integration .bashrc: %v
- error writing bash-integration bash_preexec.sh: %v
- error writing fish-integration wave.fish: %v
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/c3ef1292500405b9.
Report an issue: GitHub.