chenhg5/cc-connect · error
another cc-connect instance is already running with config %
Error message
another cc-connect instance is already running with config %s
What it means
Windows lock-contention fallback: CreateFile failed but readPIDFromLockFile could not recover a positive PID (empty/corrupt lock file), so the error reports only the config path. It still means the lock file cannot be opened for exclusive use — another instance or an OS-level file problem.
Source
Thrown at cmd/cc-connect/instance_lock_windows.go:54
return nil, fmt.Errorf("cannot convert lock path: %w", err)
}
handle, createErr := syscall.CreateFile(
pathPtr,
syscall.GENERIC_READ|syscall.GENERIC_WRITE,
syscall.FILE_SHARE_READ,
nil,
syscall.OPEN_ALWAYS,
syscall.FILE_ATTRIBUTE_NORMAL,
0,
)
if createErr != nil {
pid := readPIDFromLockFile(lockPath)
if pid > 0 {
return nil, fmt.Errorf("another cc-connect instance is already running (PID %d) with config %s", pid, configPath)
}
return nil, fmt.Errorf("another cc-connect instance is already running with config %s", configPath)
}
pid := os.Getpid()
syscall.SetFilePointer(handle, 0, nil, syscall.FILE_BEGIN)
syscall.SetEndOfFile(handle)
var written uint32
syscall.WriteFile(handle, []byte(fmt.Sprintf("%d\n", pid)), &written, nil)
syscall.FlushFileBuffers(handle)
return &InstanceLock{
handle: handle,
path: lockPath,
acquired: true,
}, nil
}
func (l *InstanceLock) Release() {
if l == nil || !l.acquired {View on GitHub (pinned to 4000b2338a)
Solutions
- Check the actual Win32 error behind createErr in logs — sharing violation means a live holder, access denied means permissions.
- Identify the holder (Resource Monitor / handle.exe on the lock file) and stop it if it is a cc-connect process.
- Delete the stale lock file if no process holds it.
- Check ACLs on the config directory (icacls) if the error is access-denied rather than sharing-violation.
Defensive patterns
Strategy: try-catch
Try / catch
lock, err := AcquireInstanceLock(configPath)
if err != nil && strings.HasPrefix(err.Error(), "another cc-connect instance is already running") {
// PID unknown on Windows — check the lock file with handle.exe/Resource Monitor
fmt.Fprintln(os.Stderr, "lock held by unknown process; inspect", lockPath)
os.Exit(1)
} Prevention
- Check icacls on the config dir when this recurs without a running instance.
- Exclude the config dir from antivirus/OneDrive sync locking.
- Delete stale lock files only after confirming no holder.
When it happens
Trigger: syscall.CreateFile returns an error on the lock path and readPIDFromLockFile returns <= 0; could be sharing violation from another process or an access-denied/invalid-path condition.
Common situations: Previous instance crashed before writing its PID; lock file created by another user (access denied); antivirus or sync tool holding the file open.
Related errors
- another cc-connect instance is already running (PID %d) with
- another cc-connect instance is already running (PID %d) with
- another cc-connect instance is already running with config %
- cannot create config directory: %w
- cannot convert lock path: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/089dabf3ecc5407d.
Report an issue: GitHub.