chenhg5/cc-connect · error
start: %s (%w)
Error message
start: %s (%w)
What it means
Start() wraps a failure of `systemctl start cc-connect`, including systemctl's stdout in the message. It means the service could not be started, either because systemctl itself failed to talk to systemd or because the service unit failed to activate.
Source
Thrown at daemon/systemd.go:108
if _, err := runSystemctl(m.sysArgs("disable", "--now", systemdServiceName)...); err != nil {
slog.Warn("systemd: disable failed", "error", err)
}
unitPath := m.unitPath()
if err := os.Remove(unitPath); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("remove unit: %w", err)
}
if _, err := runSystemctl(m.sysArgs("daemon-reload")...); err != nil {
slog.Warn("systemd: daemon-reload failed", "error", err)
}
return nil
}
func (m *systemdManager) Start() error {
out, err := runSystemctl(m.sysArgs("start", systemdServiceName)...)
if err != nil {
return fmt.Errorf("start: %s (%w)", out, err)
}
return nil
}
func (m *systemdManager) Stop() error {
out, err := runSystemctl(m.sysArgs("stop", systemdServiceName)...)
if err != nil {
return fmt.Errorf("stop: %s (%w)", out, err)
}
return nil
}
func (m *systemdManager) Restart() error {
out, err := runSystemctl(m.sysArgs("restart", systemdServiceName)...)
if err != nil {
return fmt.Errorf("restart: %s (%w)", out, err)
}
return nilView on GitHub (pinned to 4000b2338a)
Solutions
- Read the embedded systemctl stdout for the activation failure reason.
- Ensure the unit is installed: `systemctl cat cc-connect` (install first if missing).
- Confirm systemd is running: `systemctl is-system-running`; enable it in WSL2 via /etc/wsl.conf.
- Check service logs: `journalctl -u cc-connect -e` for ExecStart errors.
Example fix
// before
mgr.Start() // start: Failed to start cc-connect.service: Unit is masked
// after
if st, _ := mgr.Status(); st == nil || !st.Running {
return fmt.Errorf("cc-connect unit not installed; run install first")
}
mgr.Start() Defensive patterns
Strategy: validation
Validate before calling
if _, err := os.Stat(mgr.unitPath()); err != nil {
return fmt.Errorf("unit not installed; run install first")
}
if out, err := exec.Command("systemctl", "is-system-running").Output(); err != nil {
return fmt.Errorf("systemd unavailable (%s): %w", strings.TrimSpace(string(out)), err)
} Type guard
func serviceStartable(unitPath string) bool {
if _, err := os.Stat(unitPath); err != nil { return false }
return exec.Command("systemctl", "is-system-running").Run() == nil
} Try / catch
if err := mgr.Start(); err != nil {
if strings.Contains(err.Error(), "not loaded") || strings.Contains(err.Error(), "not found") {
return fmt.Errorf("install the unit first: %w", err)
}
return err
} Prevention
- Install the unit before calling Start.
- Enable systemd in WSL2 before daemon operations.
- Check journalctl -u cc-connect when start fails.
- Avoid masking the unit with admin overrides.
When it happens
Trigger: Calling Start when the unit is not installed, systemd is not running (WSL2/containers), the service is masked, or the service's ExecStart fails immediately.
Common situations: Start called before Install; WSL2 without systemd=true in wsl.conf; the configured agent binary missing from PATH for the service user; unit disabled and masked by an admin.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- systemctl %s: %s (%w)
- stop: %s (%w)
- restart: %s (%w)
- antigravitySession: stdout pipe: %w
- antigravitySession: start: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/74887c10851affe6.
Report an issue: GitHub.