jackwener/OpenCLI · error · ArgumentError
--file path does not exist: ${filePath}
Error message
--file path does not exist: ${filePath} What it means
readFileForUpload throws this ArgumentError when fs.statSync fails on the resolved --file path, meaning the path cannot be stated (does not exist, is inaccessible, or a broken symlink). The library validates the file before reading/base64-encoding it for a NotebookLM upload, and this is the first guard in that chain.
Source
Thrown at clis/notebooklm/add-source.js:45
'.epub': 'application/epub+zip',
'.mp3': 'audio/mpeg',
'.m4a': 'audio/mp4',
'.wav': 'audio/wav',
};
export function inferMimeType(filename, override) {
if (override) return String(override);
const ext = path.extname(filename).toLowerCase();
return MIME_BY_EXT[ext] || 'application/octet-stream';
}
export function readFileForUpload(filePath) {
const abs = path.resolve(filePath);
let stat;
try {
stat = fs.statSync(abs);
} catch {
throw new ArgumentError(`--file path does not exist: ${filePath}`);
}
if (!stat.isFile()) {
throw new ArgumentError(`--file path is not a regular file: ${filePath}`);
}
if (stat.size > MAX_FILE_SOURCE_BYTES) {
throw new ArgumentError(`--file exceeds ${MAX_FILE_SOURCE_BYTES} bytes (got ${stat.size}); use a smaller file or upload via the NotebookLM UI for now.`);
}
const buf = fs.readFileSync(abs);
return { base64: buf.toString('base64'), filename: path.basename(abs), size: stat.size };
}
export function buildRegisterFileSourceArgs(projectId, filename) {
return [
[[filename]],
projectId,
[2],
[1, null, null, null, null, null, null, null, null, null, [1]],
];View on GitHub (pinned to 49907e53dc)
Solutions
- Check the path with `ls -l <path>` (or fs.existsSync) and correct typos.
- Run the command from the directory you assumed, or pass an absolute path.
- Verify file permissions and that the symlink target exists.
- Confirm the file exists in the environment (container/mount) where the command executes.
Example fix
// before
addSource({ file: './nots/report.pdf' });
// after
addSource({ file: './notes/report.pdf' }); // or path.resolve to an absolute path Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
if (!fs.existsSync(filePath)) throw new Error(`--file not found: ${filePath}`);
if (!fs.statSync(filePath).isFile()) throw new Error(`--file is not a regular file: ${filePath}`); Type guard
function isExistingFile(p) { try { return fs.statSync(p).isFile(); } catch { return false; } } Try / catch
try {
await addSource({ file: filePath });
} catch (e) {
if (e instanceof ArgumentError && e.message.includes('--file path does not exist')) {
console.error(`Fix the path: ${path.resolve(filePath)}`);
} else throw e;
} Prevention
- Always pass absolute paths (path.resolve) so cwd doesn't matter.
- Check fs.existsSync + isFile before invoking the command.
- Quote paths in the shell to avoid truncation on spaces.
- Watch for broken symlinks when paths are generated by scripts.
When it happens
Trigger: Calling the add-source command with --file pointing to a non-existent path, a typo'd filename, a dangling symlink, or a path the process lacks permission to stat (statSync throws).
Common situations: Relative path typed from a different working directory than expected; file deleted or renamed before the command ran; shell quoting issues truncating the path; running on a machine/container where the file was never mounted.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- --file path is not a regular file: ${filePath}
- File not found: ${path}
- File must be a readable text file: ${path}
- 视频文件不存在: ${videoPath}
- Video file not found: ${resolved}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/dbe4a41fd564a6b2.
Report an issue: GitHub.