cube-js/cube · error

{} is not a directory

Error message

{} is not a directory

What it means

Raised by `cube deploy` (data-model deploy command) before any network work: the --directory argument supplied does not exist on disk or exists but is not a directory. The CLI validates args.directory.is_dir() up front and refuses to proceed, so a mistyped path fails fast instead of producing an empty upload.

Source

Thrown at rust/cube-cli/src/commands/deploy.rs:76

            out.push((rel, path));
        }
    }
    Ok(())
}

fn sha1_hex(data: &[u8]) -> String {
    let mut hasher = Sha1::new();
    hasher.update(data);
    format!("{:x}", hasher.finalize())
}

pub async fn command(args: Args, ctx: &Ctx) -> Result<()> {
    let api = ctx.api()?;
    let deployment = args.deployment;
    let base = format!("/build/api/v1/deployments/{deployment}/data-model");

    if !args.directory.is_dir() {
        bail!("{} is not a directory", args.directory.display());
    }
    let mut files = Vec::new();
    collect_files(&args.directory, &args.directory, &mut files)?;
    if files.is_empty() {
        bail!("no deployable files found in {}", args.directory.display());
    }
    files.sort();

    // Hash local files and diff against the server's content hashes.
    let mut query = Vec::new();
    util::push(&mut query, "branchName", &args.branch);
    let upstream = api.get(&format!("{base}/file-hashes"), &query).await?;
    let upstream = upstream.get("files").cloned().unwrap_or(upstream);

    let mut manifest = serde_json::Map::new();
    let mut to_upload = Vec::new();
    for (rel, path) in &files {
        let data =

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Check the path exists with `ls <path>` and correct the --directory value.
  2. Run from the directory where the relative path resolves, or pass an absolute path.
  3. If you pointed at a file, pass the containing data-model/schema directory instead.
  4. In CI, ensure the checkout step creates the expected directory before deploying.

Example fix

// before
run: cube deploy 42 --directory ./schema   # dir is actually ./data-model
// after
run: cube deploy 42 --directory ./data-model
Defensive patterns

Strategy: validation

Validate before calling

let dir = std::path::Path::new(&args.directory);
if !dir.is_dir() {
    anyhow::bail!("--directory must be an existing directory, got: {}", args.directory.display());
}

Try / catch

match result {
    Err(e) if e.to_string().ends_with("is not a directory") => {
        // print usage hint with the expected schema directory path
    }
    other => other?,
}

Prevention

When it happens

Trigger: `cube deploy <deployment> --directory <path>` where the path does not exist, is a regular file (e.g. someone passed a schema file instead of the folder), or is a symlink to a removed target.

Common situations: Typo in the schema directory path; running the CLI from a different working directory in CI so a relative path no longer resolves; passing the repository root file path instead of the data-model directory; deleted checkout directory.

Related errors


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