cube-js/cube · error
provide --file <path> or --content <text>
Error message
provide --file <path> or --content <text>
What it means
The data model write/update commands require the content to come from somewhere: a --file path, '-' for stdin, or inline --content text. read_content bails with this error when none of these were supplied, since there is nothing to send.
Source
Thrown at rust/cube-cli/src/commands/data_model.rs:321
output::success(&format!(
"Disabled branch {branch}; its staging environment is active only while viewed"
));
}
Ok(())
}
fn read_content(file: Option<String>, content: Option<String>) -> Result<String> {
if let Some(path) = file {
return std::fs::read_to_string(&path).with_context(|| format!("failed to read {path}"));
}
match content.as_deref() {
Some("-") => {
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf)?;
Ok(buf)
}
Some(c) => Ok(c.to_string()),
None => anyhow::bail!("provide --file <path> or --content <text>"),
}
}
/// The command that opens a branch for compilation, rendered in one place.
///
/// Three messages hand it over — the `Branch is not active` verdict and the
/// `none`/`stopped` backstop in [`crate::commands::deployments`], and `create-branch
/// --dev-mode` below — and their prose deliberately differs: one answers a verdict, one
/// answers absence, one follows a branch that was just created. What a reader COPIES
/// shouldn't differ, so only the sentences around it are written three times. It lives
/// here because this module owns the subcommand it names.
///
/// The branch is user-supplied and goes into a command meant to be pasted, so it is
/// quoted — see [`util::shell_quote`] for what a legal ref name can do unquoted.
pub fn dev_mode_command(deployment: i64, branch: &str) -> String {
format!(
"`cube data-model dev-mode {deployment} {}`",
util::shell_quote(branch)View on GitHub (pinned to 7d981676b3)
Solutions
- Add --content "<text>" with the model definition inline
- Add --file <path> pointing to the model file (or --file - to read stdin)
- In scripts, guard against empty variables: only invoke with --file "$MODEL_FILE" if non-empty
- Pipe the content: cat model.yml | cube data-model put --file -
Example fix
// before cube data-model put --path schema/model.yml # no content source // after cube data-model put --path schema/model.yml --file schema/model.yml
Defensive patterns
Strategy: validation
Validate before calling
const hasFile = Boolean(args.file && args.file.length);
const hasContent = Boolean(args.content && args.content.length);
if (!hasFile && !hasContent) { throw new Error('Pass --file <path> (or --file - for stdin) or --content <text>'); } Type guard
function hasContentSource(a: { file?: string; content?: string }): a is { file: string } | { content: string } {
return Boolean(a.file?.length) || Boolean(a.content?.length);
} Try / catch
try {
await putDataModel(args);
} catch (e) {
if (/provide --file|--content/.test(String(e))) { console.error('Supply --file or --content'); process.exit(2); }
throw e;
} Prevention
- Always pass --file or --content explicitly in scripts
- Use `--file -` with a heredoc/pipe for generated content
- Quote path variables so empty shell vars are detectable
- Prefer --file over --content for anything beyond a few lines
When it happens
Trigger: Running `cube data-model put`-style commands without --file and without --content (both flags omitted); passing empty-valued flags in scripts.
Common situations: Scripted CI updates where a variable holding the file path was empty; users forgetting that --file and --content are mutually required alternatives; piping forgotten (expected stdin default but none configured).
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Can't parse date: '${from}'
- Can't parse date: '${to}'
- Can't parse date: '${dateString}'
- API URL is empty
- context `{name}` not found (run `cube login --name {name}`)
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/b3825091843bdb53.
Report an issue: GitHub.