cube-js/cube · error

file not found: {path}

Error message

file not found: {path}

What it means

The data-model file read command fetches the repository tree from the deployment API and searches it for the requested path. If no tree node matches the path (and is a file), it fails with 'file not found: {path}'.

Source

Thrown at rust/cube-cli/src/commands/data_model.rs:384

                        println!("{path}");
                    }
                }
            }
        }
        Cmd::Get {
            deployment,
            path,
            branch,
        } => {
            let mut query: Query = vec![("withContent".into(), "true".into())];
            util::push(&mut query, "branchName", &branch);
            let res = api.get(&base(deployment), &query).await?;
            let file = tree_nodes(&res).into_iter().find(|f| {
                same_path(&output::field(f, "path"), &path) && output::field(f, "type") == "file"
            });
            match file {
                Some(f) => print!("{}", output::field(&f, "content")),
                None => anyhow::bail!("file not found: {path}"),
            }
        }
        Cmd::Put {
            deployment,
            path,
            file,
            content,
            branch,
        } => {
            let text = read_content(file, content)?;
            let mut map = serde_json::Map::new();
            map.insert("files".into(), json!([{ "path": path, "content": text }]));
            let res = api
                .put(&base(deployment), Some(&write_body(map, &branch)))
                .await?;
            if ctx.json {
                output::print_json(&res);
            } else {

View on GitHub (pinned to 7d981676b3)

Solutions

  1. List available files first (`cube data-model tree` or equivalent) and copy the exact path
  2. Fix the path casing/leading slashes to match the repo-relative path exactly
  3. Verify you are pointed at the correct deployment/branch that contains the file
  4. Commit/push the model file to the deployment's repository if it was recently added

Example fix

// before
cube data-model get --path /schema/orders.yml   # leading slash, not found
// after
cube data-model get --path schema/orders.yml
Defensive patterns

Strategy: validation

Validate before calling

const tree = await cube.dataModel.tree({ deployment });
const normalized = path.replace(/^\.?\//, '');
if (!tree.some(f => f.type === 'file' && f.path === normalized)) {
  throw new Error(`'${normalized}' not in deployment tree — list files and use the exact path`);
}

Type guard

function findFileExact(tree: { path: string; type: string }[], p: string) {
  const norm = p.replace(/^\.?\//, '');
  return tree.find(f => f.type === 'file' && f.path === norm) ?? null;
}

Try / catch

try {
  await getDataModelFile(path);
} catch (e) {
  if (/file not found/.test(String(e))) { const tree = await listTree(); console.error('Available:', tree.map(f => f.path)); }
  throw e;
}

Prevention

When it happens

Trigger: Running `cube data-model get --path <p>` where <p> does not exactly match a file path in the deployment's data model repository — wrong case, leading/trailing slash, wrong directory, or the file was deleted.

Common situations: Requesting schema files by path from memory instead of listing the tree first; path casing mismatches; querying a branch/deployment where the file doesn't exist yet; paths written with leading './' or absolute prefixes.

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/e276ff398c6aed96. Report an issue: GitHub.