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
- List available files first (`cube data-model tree` or equivalent) and copy the exact path
- Fix the path casing/leading slashes to match the repo-relative path exactly
- Verify you are pointed at the correct deployment/branch that contains the file
- 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
- Copy paths from `data-model tree` output instead of typing them
- Normalize paths: strip leading slashes, match case exactly
- Confirm the deployment/branch actually contains the file before fetching
- Add a pre-check that searches the tree before requesting file content
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
- context `{name}` not found (run `cube login --name {name}`)
- provide --file <path> or --content <text>
- Can't parse date: '${from}'
- Can't parse date: '${to}'
- Can't parse date: '${dateString}'
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/e276ff398c6aed96.
Report an issue: GitHub.