openclaw/openclaw · error · Error
Refusing to overwrite foreign Chrome extension directory: ${
Error message
Refusing to overwrite foreign Chrome extension directory: ${target} What it means
Thrown by installStableChromeExtension when an existing target directory is present but is not marked as owned by OpenClaw (no valid OWNED_COPY_MARKER with v:1). The installer will not overwrite a Chrome extension directory it did not create, to avoid clobbering a user's manually-installed extension or one owned by another tool.
Source
Thrown at extensions/browser/src/browser/extension-install-layout.ts:269
await fs.chmod(targetPath, 0o600);
}
}
}
}
/** Copy/update the bundled extension with rollback-safe same-directory renames. */
export async function installStableChromeExtension(
bundledDir: string,
deps: ExtensionInstallDeps = {},
): Promise<string> {
const source = await fs.realpath(path.resolve(bundledDir));
await assertOwnedPath(source, "directory", { allowRootOwner: true });
const target = stableChromeExtensionDir(deps);
await ensurePrivateDirectory(path.resolve(deps.stateDir ?? resolveStateDir(deps.env)));
await ensurePrivateDirectory(path.dirname(target));
const existing = await inspectInstalledCopy(target);
if (existing.present && !existing.owned) {
throw new Error(`Refusing to overwrite foreign Chrome extension directory: ${target}`);
}
const suffix = `${process.pid}-${crypto.randomBytes(6).toString("hex")}`;
const temporary = `${target}.tmp-${suffix}`;
const previous = `${target}.previous-${suffix}`;
try {
await copyRuntimeTree(source, temporary);
await fs.writeFile(
path.join(temporary, OWNED_COPY_MARKER),
`${JSON.stringify({ v: 1, owner: "openclaw" })}\n`,
{ mode: 0o600, flag: "wx" },
);
if (existing.present) {
await fs.rename(target, previous);
}
try {
await fs.rename(temporary, target);
} catch (error) {
if (existing.present) {View on GitHub (pinned to 01804a7531)
Solutions
- Inspect the target directory; if it is safe to remove, delete it and rerun the installer.
- If the directory should be owned by OpenClaw, recreate the OWNED_COPY_MARKER with {"v":1,"owner":"openclaw"}.
- Point the state dir elsewhere to install into a fresh location.
Example fix
// before $ openclaw browser extension install # target dir exists, not owned // after $ rm -rf ~/.openclaw/browser/chrome-extension && openclaw browser extension install
Defensive patterns
Strategy: try-catch
Validate before calling
const existing = await inspectInstalledCopy(target);
if (existing.present && !existing.owned) {
throw new Error('target has foreign extension dir; remove it first');
} Try / catch
try { await installStableChromeExtension(bundledDir); }
catch (err) {
if (/foreign Chrome extension directory/.test(String(err))) {
await fs.rm(target, { recursive: true, force: true });
await installStableChromeExtension(bundledDir);
} else throw err;
} Prevention
- Let OpenClaw own the extension directory exclusively.
- Remove foreign extension dirs before first install.
- Do not share the extension directory with other tools.
When it happens
Trigger: A previous manual install of the Chrome extension in the same target; a leftover directory from an older OpenClaw version that predated the ownership marker; a foreign tool that writes to the same path; a marker file that got corrupted or removed.
Common situations: Switching from a manual install to the managed installer; downgrading OpenClaw past the marker version; another Chrome extension manager claiming the same directory; partial cleanup that removed the marker.
Related errors
- Refusing foreign owner at ${target}
- Refusing symlink in bundled Chrome extension: ${sourcePath}
- Unsafe ${kind} at ${target}
- Refusing group/world-writable path at ${target}
- Could not resolve the user home directory.
AI-assisted analysis of openclaw/openclaw@01804a7531 (2026-08-12).
Data as JSON: /api/errors/c7e33b3acf8bec5b.
Report an issue: GitHub.