cube-js/cube · error · Error

Model files not found. Please make sure the "${this.reposito

Error message

Model files not found. Please make sure the "${this.repositoryPath}" directory exists and contains model files.

What it means

Startup guard in FileRepository.getFiles: the configured schema directory (repositoryPath, e.g. the /model folder relative to cwd) could not be read by fs.readdir. It fires when the schema directory does not exist or is unreadable, meaning no data models can be compiled — a fatal configuration/environment problem at repository access time.

Source

Thrown at packages/cubejs-backend-shared/src/FileRepository.ts:34

export class FileRepository implements SchemaFileRepository {
  public constructor(
    protected readonly repositoryPath: string
  ) {
  }

  public localPath(): string {
    return path.join(process.cwd(), this.repositoryPath);
  }

  protected async getFiles(dir: string, fileList: string[] = []): Promise<string[]> {
    let files: string[] = [];

    try {
      const fullPath = path.join(this.localPath(), dir);
      await fs.ensureDir(fullPath);
      files = await fs.readdir(fullPath);
    } catch (e) {
      throw new Error(`Model files not found. Please make sure the "${this.repositoryPath}" directory exists and contains model files.`);
    }

    // eslint-disable-next-line no-restricted-syntax
    for (const file of files) {
      const stat = await fs.stat(path.join(this.localPath(), dir, file));
      if (stat.isDirectory()) {
        fileList = await this.getFiles(path.join(dir, file), fileList);
      } else fileList.push(path.join(dir, file));
    }

    return fileList;
  }

  public async dataSchemaFiles(includeDependencies: boolean = false): Promise<FileContent[]> {
    const files = await this.getFiles('');

    let result = await Promise.all(
      files

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Create the schema directory (by default ./model relative to the project working directory) and add at least one model file.
  2. Verify the CUBEJS_SCHEMA_PATH / repositoryPath configuration points to the right location.
  3. Check that the process working directory and file permissions allow reading the directory.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/cubejs-backend-shared/src/FileRepository.ts:34 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/411226395d12a05f. Report an issue: GitHub.