chenhg5/cc-connect · error
save config: %w
Error message
save config: %w
What it means
After modifying the management/bridge sections, EnableWebAdmin persists the Config via saveConfig(cfg); a failure there is wrapped as "save config: %w". saveConfig typically serializes to TOML and writes the file, so this covers serialization errors and filesystem write/permission failures.
Source
Thrown at config/config.go:3966
changed = true
}
if !bridgeEnabled {
cfg.Bridge.Enabled = &t
if cfg.Bridge.Port == 0 {
cfg.Bridge.Port = 9810
}
if cfg.Bridge.Token == "" {
cfg.Bridge.Token = bridgeToken
}
if len(cfg.Bridge.CORSOrigins) == 0 {
cfg.Bridge.CORSOrigins = []string{"*"}
}
changed = true
}
if changed {
if err := saveConfig(cfg); err != nil {
return nil, fmt.Errorf("save config: %w", err)
}
}
return &WebSetupResult{
ManagementPort: orDefault(cfg.Management.Port, 9820),
ManagementToken: cfg.Management.Token,
BridgePort: orDefault(cfg.Bridge.Port, 9810),
BridgeToken: cfg.Bridge.Token,
AlreadyEnabled: false,
}, nil
}
func orDefault(v, d int) int {
if v == 0 {
return d
}
return v
}View on GitHub (pinned to 4000b2338a)
Solutions
- Check and fix permissions: ensure the process user can write config.toml (chown/chmod 600, writable parent directory)
- Free disk space / address read-only mount if the FS is full or ro
- If root-owned, re-run setup with elevated privileges or transfer ownership: sudo chown $USER config.toml
- Inspect the inner wrapped error from saveConfig to distinguish write vs serialization failure
Example fix
// before sudo cc-connect setup-web # writes root-owned config // after sudo chown $USER ~/.cc-connect/config.toml && cc-connect setup-web
Defensive patterns
Strategy: try-catch
Validate before calling
if fi, err := os.Stat(config.ConfigPath); err == nil {
if err := syscall.Access(config.ConfigPath, os.O_WRONLY); err != nil {
return fmt.Errorf("config.toml not writable by current user")
}
} Try / catch
if err := config.EnableWebAdmin(t, b); err != nil {
if strings.Contains(err.Error(), "save config") {
slog.Error("could not persist config; check disk space and file ownership", "err", err)
}
return err
} Prevention
- Keep config.toml owned and writable by the daemon user
- Monitor disk space where the config lives
- Prefer re-running setup with correct privileges over sudo-copying root-owned files
- Use atomic rename writes so partial saves never corrupt the file
When it happens
Trigger: The config directory or file is read-only (chmod/ownership problem); the filesystem is full or mounted read-only; TOML serialization of the modified Config fails; the process lacks write permission on config.toml (e.g. editing the file requires root).
Common situations: config.toml owned by root while the daemon runs as a normal user; ~/.config directory missing or not writable; disk quota exceeded; running the setup command without sudo against a system-wide config.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- pi: read settings: %w
- create temp config: %w
- create temp file: %w
- parse existing Agy hooks %s: %w
- read existing Agy hooks %s: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/9e7c8d9cf6f9236b.
Report an issue: GitHub.