abhigyanpatwari/GitNexus · error · Error
auto-sync clone root is owned by uid ${stat.uid}, not curren
Error message
auto-sync clone root is owned by uid ${stat.uid}, not current process uid What it means
Thrown by assertDirectoryOwnerAndPermissions (POSIX only; skipped on Windows) when the clone root directory's st_uid differs from the current process uid. A root owned by another user could be modified by that user's processes, letting them inject content into repositories that auto-sync clones and indexes, so the guard refuses to trust it. This check runs on every watch tick, so the failure persists until ownership is fixed.
Source
Thrown at gitnexus/src/core/auto-sync/path-security.ts:270
}
if (stat.isSymbolicLink())
throw new Error(`Refusing symlink in auto-sync clone root path: ${current}`);
}
}
export async function assertDirectoryOwnerAndPermissions(root: string): Promise<void> {
const stat = await fs.stat(root);
if (!stat.isDirectory()) throw new Error(`auto-sync clone root is not a directory: ${root}`);
// POSIX uid/mode have no meaning on Windows, and this runs on every tick for
// every project, so throwing here failed 100% of repos forever while `watch
// status` still read `running`. Skip the ownership assertions rather than the
// whole feature: the caller's other guards — dangerous-root rejection
// (including the Windows system roots), symlink refusal, realpath containment
// and the GitNexus-internal-root check — all still apply, and managed git runs
// with `core.hooksPath` pinned to the null device.
if (process.platform === 'win32') return;
if (typeof process.getuid === 'function' && stat.uid !== process.getuid()) {
throw new Error(`auto-sync clone root is owned by uid ${stat.uid}, not current process uid`);
}
const mode = stat.mode & 0o777;
const groupWritable = (mode & 0o020) !== 0;
const worldWritable = (mode & 0o002) !== 0;
if (worldWritable) {
throw new Error(`Refusing world-writable auto-sync clone root: ${root}`);
}
if (groupWritable) {
throw new Error(`Refusing group-writable auto-sync clone root: ${root}`);
}
}
function assertContainedOrSame(root: string, child: string, message: string): void {
const rel = path.relative(root, child);
if (rel.startsWith('..') || path.isAbsolute(rel)) throw new Error(message);
}
View on GitHub (pinned to 0d1aed942f)
Solutions
- chown the clone-root directory (and its contents) to the uid running the GitNexus watcher: sudo chown -R $(id -u):$(id -g) <root>
- Recreate the directory as the watcher user if it was created by root or another account
- Move the clone root to a directory under the watcher user's home or the GitNexus global dir, which the process owns
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at gitnexus/src/core/auto-sync/path-security.ts:270 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-09-08).
Data as JSON: /api/errors/22257d9d6fe536c8.
Report an issue: GitHub.