cube-js/cube · error · UserError

'${dbtProjectPath}' was not found. Please make sure '${proje

Error message

'${dbtProjectPath}' was not found. Please make sure '${projectPath}' is a path to the dbt project

What it means

loadMetricCubesFromDbtProject expects projectPath to be the root of a compiled dbt project containing dbt_project.yml. Before reading anything else it joins projectPath with 'dbt_project.yml' and throws this UserError if the file does not exist, indicating the given path is not a dbt project.

Source

Thrown at packages/cubejs-dbt-schema-extension/src/Dbt.ts:139

  sum: 'sum',
  average: 'avg',
  min: 'min',
  max: 'max',
};

function mapMetricType(dbtMetricType: string): string {
  if (!dbtToCubeMetricTypeMap[dbtMetricType]) {
    throw new UserError(`Unsupported dbt metric type '${dbtMetricType}'`);
  }

  return dbtToCubeMetricTypeMap[dbtMetricType];
}

export class Dbt extends AbstractExtension {
  public async loadMetricCubesFromDbtProject(projectPath: string, options: DbtLoadOptions): Promise<{ [cubeName: string]: any }> {
    const dbtProjectPath = path.join(projectPath, 'dbt_project.yml');
    if (!(await fs.pathExists(dbtProjectPath))) {
      throw new UserError(`'${dbtProjectPath}' was not found. Please make sure '${projectPath}' is a path to the dbt project`);
    }
    // TODO read target path from dbt_project.yml
    const manifestPath = path.join(projectPath, 'target', 'manifest.json');
    if (!(await fs.pathExists(manifestPath))) {
      throw new UserError(`'${manifestPath}' was not found. Please run 'dbt compile' in '${projectPath}'`);
    }
    const manifest = <DbtManifest>(await fs.readJSON(manifestPath));
    Object.keys(manifest.metrics).forEach(metric => {
      const regex = /^ref\('(\S+)'\)$/;
      const metricDef = manifest.metrics[metric];
      const match = metricDef.model.match(regex);
      if (!match) {
        throw new UserError(`Expected reference to the model in format ref('model_name') but found '${metricDef.model}'`);
      }
      // eslint-disable-next-line prefer-destructuring
      const modelName = match[1];
      metricDef.model = modelName.indexOf('.') !== -1 ? modelName : `model.${metricDef.package_name}.${modelName}`;
    });

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Point the configured dbt project path at the directory that directly contains dbt_project.yml
  2. Verify the path with ls <path>/dbt_project.yml (or fs.pathExists) before loading
  3. Fix relative paths by making the path absolute (path.resolve) relative to the process cwd
  4. If the dbt project lives in a subfolder of the repo, include that subfolder in the configured path

Example fix

// before
new Dbt(compiler).loadMetricCubesFromDbtProject('repo', {})
// after
new Dbt(compiler).loadMetricCubesFromDbtProject('repo/dbt_analytics', {})
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs-extra');
const p = path.resolve(process.cwd(), dbtProjectPath);
if (!(await fs.pathExists(path.join(p, 'dbt_project.yml')))) {
  throw new Error(`${p} is not a dbt project (dbt_project.yml missing)`);
}

Try / catch

try {
  await dbt.loadMetricCubesFromDbtProject(projectPath, opts);
} catch (e) {
  if (e.message.includes('was not found')) {
    console.error(`Check DBT project path; resolved: ${path.resolve(projectPath)}`);
  } else { throw e; }
}

Prevention

When it happens

Trigger: Calling Dbt.loadMetricCubesFromDbtProject(projectPath, options) with a directory that has no dbt_project.yml at its root — wrong directory, typo in path, pointing at the repository root or target/ instead of the project root, or dbt project not yet initialized.

Common situations: Misconfigured repositoryPath/dbt config in cube.js pointing to the wrong folder; running Cube from a different working directory with a relative path; CI checkout that excludes the dbt project; passing the folder containing target/ rather than the project root itself.

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 cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/7dfe2649216f811d. Report an issue: GitHub.