abhigyanpatwari/GitNexus · error
Group " " already exists. Use --force to overwrite.
Error message
Group "${groupName}" already exists. Use --force to overwrite. What it means
Thrown by createGroupDir() in gitnexus/src/core/group/storage.ts when the target group directory already contains a group.yaml (the marker of an initialized group) and force is false. It protects an existing group's config and member repos from being silently overwritten by the YAML template.
Solutions
- Pass --force (force=true in createGroupDir) when you intentionally want to overwrite the existing group
- Make the setup script idempotent: check whether <gitnexusDir>/groups/<name>/group.yaml exists before creating
- Use a different group name if this is meant to be a new, separate group
Example fix
// before await createGroupDir(gitnexusDir, 'my-group'); // throws if group.yaml exists // after await createGroupDir(gitnexusDir, 'my-group', /* force */ true);
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'node:fs';
import path from 'node:path';
const groupYaml = path.join(gitnexusDir, 'groups', groupName, 'group.yaml');
if (fs.existsSync(groupYaml)) {
if (!shouldOverwrite) {
console.log(`Group ${groupName} already exists — skipping (idempotent).`);
process.exit(0);
}
}
await createGroupDir(gitnexusDir, groupName, shouldOverwrite); Try / catch
try {
await createGroupDir(gitnexusDir, groupName, force);
} catch (err) {
if (err instanceof Error && err.message.includes('already exists')) {
// decide: skip, pick a new name, or re-call with force=true
}
throw err;
} Prevention
- Make provisioning scripts idempotent: probe for groups/<name>/group.yaml before creating
- Treat 'already exists' as a success signal in setup automation, not a failure
- Only pass --force when you intend to discard the group's current config and members
When it happens
Trigger: Running the group-create command twice with the same groupName without --force, e.g. re-running `gitnexus group create my-group` after the first invocation already wrote groups/my-group/group.yaml.
Common situations: Idempotent bootstrap or provisioning scripts that create groups on every run; CI pipelines that re-execute a setup step; retrying a command that actually succeeded the first time.
Related errors
- analyze --watch does not support
- analyze --watch does not support
- Could not install the embedding runtime
- Could not verify persisted embedding count.
- is too large
AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-08-20).
Data as JSON: /api/errors/4dbcbbd26353c692.
Report an issue: GitHub.
Appendix: source
Thrown at gitnexus/src/core/group/storage.ts:83
names.push(entry.name);
}
}
}
return names;
} catch (err: unknown) {
if ((err as NodeJS.ErrnoException).code === 'ENOENT') return [];
throw err;
}
}
export async function createGroupDir(
gitnexusDir: string,
groupName: string,
force: boolean = false,
): Promise<string> {
const groupDir = getGroupDir(gitnexusDir, groupName);
if (fs.existsSync(path.join(groupDir, 'group.yaml')) && !force) {
throw new Error(`Group "${groupName}" already exists. Use --force to overwrite.`);
}
await fsp.mkdir(groupDir, { recursive: true });
const template = `version: 1
name: ${groupName}
description: ""
repos: {}
links: []
packages: {}
detect:
http: true
graphql: false
grpc: true
topics: trueView on GitHub (pinned to 0d1aed942f)