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

  1. Check the path with `ls -l <path>` (or fs.existsSync) and correct typos.
  2. Run the command from the directory you assumed, or pass an absolute path.
  3. Verify file permissions and that the symlink target exists.
  4. 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

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/dbe4a41fd564a6b2. Report an issue: GitHub.