can1357/oh-my-pi · error
memory:// URL must resolve to a file or directory: ${url.hre
Error message
memory:// URL must resolve to a file or directory: ${url.href} What it means
tryResolveInRoot stats the realpath'd target under the memory root and returns a directory listing for directories or file content for regular files. Anything else — symlinks to non-regular targets are already realpath'd, so this is typically devices, sockets, or FIFOs that ended up inside the memory root — cannot be served as a resource, so it throws.
Source
Thrown at packages/coding-agent/src/internal-urls/memory-protocol.ts:185
}
}
let realTargetPath: string;
try {
realTargetPath = await fs.realpath(targetPath);
} catch (error) {
if (isEnoent(error)) return undefined;
throw error;
}
ensureWithinRoot(realTargetPath, resolvedRoot);
const stat = await fs.stat(realTargetPath);
if (stat.isDirectory()) {
return buildDirectoryResource(url.href, realTargetPath);
}
if (!stat.isFile()) {
throw new Error(`memory:// URL must resolve to a file or directory: ${url.href}`);
}
const content = await Bun.file(realTargetPath).text();
const contentType: InternalResource["contentType"] = isMarkdownPath(realTargetPath) ? "text/markdown" : "text/plain";
return {
url: url.href,
content,
contentType,
size: Buffer.byteLength(content, "utf-8"),
sourcePath: realTargetPath,
notes: [],
};
}
/**
* Snapshot of live mnemopi session states, deduplicated. A mnemopi backend
* always keeps its state on the {@link AgentSession} it was initialised for;View on GitHub (pinned to 9690622007)
Solutions
- Inspect the target with ls -la to see what the non-file, non-directory entry is and remove or relocate it out of the memory root.
- Point the memory:// URL at an actual markdown/text file or directory inside the memory root.
- If a tool keeps creating special files in the memory root, move the memory root or stop that tool from writing there.
Defensive patterns
Strategy: try-catch
Validate before calling
const st = await fs.stat(targetPath);
if (!st.isFile() && !st.isDirectory()) throw new Error(`Unsupported target type: ${targetPath}`); Try / catch
try {
const res = await handler.resolve(url, ctx);
} catch (err) {
if (err instanceof Error && err.message.includes("must resolve to a file or directory")) {
// inspect/remove the special file in the memory root
} else throw err;
} Prevention
- Keep sockets/FIFOs/device nodes out of the memory root directory.
- Point memory:// URLs at regular markdown/text files or directories.
- Audit memory roots if third-party tools write there.
When it happens
Trigger: Resolving a memory://root/... URL whose target path exists but is neither a directory nor a regular file (e.g. a unix socket or named pipe created inside the memory root directory), after fs.stat succeeds in tryResolveInRoot.
Common situations: Unusual files placed in .omp memory roots by other tooling (sockets from dev servers, FIFOs); virtual filesystem mounts where the target is a device node.
Related errors
- cannot stat {0}: No such file or directory
- cannot stat {0}: Not a directory
- cannot read table of mounted file systems: {error}
- using '-' to denote standard input does not work in file sys
- cannot read file system information for {file}: {error}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/b02430a63a618c40.
Report an issue: GitHub.