mastra-ai/mastra · error

No mount for path: ${path}

Error message

No mount for path: ${path}

What it means

readFile on CompositeFilesystem resolves the path against registered mount prefixes; when no mount matches, it cannot delegate the read and throws this error. The composite does not have a fallback/root mount, so any path outside all mount prefixes is unresolvable.

Source

Thrown at packages/core/src/workspace/filesystem/composite-filesystem.ts:308

    this.status = 'destroying';
    const errors: Error[] = [];
    for (const fs of this._mounts.values()) {
      try {
        await callLifecycle(fs, 'destroy');
      } catch (e) {
        errors.push(e instanceof Error ? e : new Error(String(e)));
      }
    }
    if (errors.length > 0) {
      this.status = 'error';
      throw new AggregateError(errors, 'Some filesystems failed to destroy');
    }
    this.status = 'destroyed';
  }

  async readFile(path: string, options?: ReadOptions): Promise<string | Buffer> {
    const r = this.resolveMount(path);
    if (!r) throw new Error(`No mount for path: ${path}`);
    return r.fs.readFile(r.fsPath, options);
  }

  async writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void> {
    const r = this.resolveMount(path);
    if (!r) throw new Error(`No mount for path: ${path}`);
    this.assertWritable(r.fs, path, 'writeFile');
    return r.fs.writeFile(r.fsPath, content, options);
  }

  async appendFile(path: string, content: FileContent): Promise<void> {
    const r = this.resolveMount(path);
    if (!r) throw new Error(`No mount for path: ${path}`);
    this.assertWritable(r.fs, path, 'appendFile');
    return r.fs.appendFile(r.fsPath, content);
  }

  async deleteFile(path: string, options?: RemoveOptions): Promise<void> {

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Use a path under one of the mounted prefixes; log Object.keys(mounts) to see valid roots.
  2. Mount an additional prefix covering the path you need to read (or mount '/' as catch-all).
  3. Normalize the path before calling (ensure leading '/', forward slashes, resolved relative segments).
  4. If destroy() was called, re-create the composite before further reads.

Example fix

// before
await fs.readFile('/tmp/report.txt'); // only '/data' mounted
// after
await fs.readFile('/data/reports/report.txt');
Defensive patterns

Strategy: validation

Validate before calling

function resolveMounted(path: string, mounts: Record<string, unknown>): boolean {
  const p = path.startsWith('/') ? path : '/' + path;
  return Object.keys(mounts).some(prefix => p === prefix || p.startsWith(prefix + '/'));
}
if (!resolveMounted(path, mounts)) throw new Error(`Path ${path} is not covered by any mount`);

Try / catch

try { return await composite.readFile(path); } catch (e) { if ((e as Error).message.startsWith('No mount for path')) { return readThroughFallback(path); } throw e; }

Prevention

When it happens

Trigger: await composite.readFile(path) where path's prefix doesn't match any key in mounts (e.g., reading '/etc/x' when only '/data' is mounted), or calling readFile after destroy() (mounts cleared) — also via content().

Common situations: Assuming the composite behaves like a root filesystem ('/') when only subdirectories are mounted; path normalization mismatches (missing leading slash, 'C:\\' vs '/'); reading a path after destroy().

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/864f3b71cc521445. Report an issue: GitHub.