{"record":{"id":"a53b51427defa3c8","repo":"dbt-labs/dbt-core","slug":"formula-file-not-found","errorCode":null,"errorMessage":"formula file not found: {}","messagePattern":"formula file not found: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-ci/src/homebrew/publish.rs","lineNumber":43,"sourceCode":"use std::fs;\nuse std::path::{Path, PathBuf};\nuse std::process::{Command, ExitCode, Stdio};\n\npub fn execute(args: HomebrewPublishArgs) -> ExitCode {\n    match run(args) {\n        Ok(()) => ExitCode::SUCCESS,\n        Err(e) => {\n            eprintln!(\"error: {e:#}\");\n            ExitCode::from(2)\n        }\n    }\n}\n\nfn run(args: HomebrewPublishArgs) -> Result<()> {\n    validate_release_version(&args.version)\n        .with_context(|| format!(\"invalid --version {:?}\", args.version))?;\n    if !args.formula.is_file() {\n        bail!(\"formula file not found: {}\", args.formula.display());\n    }\n    let filename = args\n        .formula\n        .file_name()\n        .and_then(|s| s.to_str())\n        .ok_or_else(|| anyhow!(\"formula path has no filename: {}\", args.formula.display()))?\n        .to_string();\n    if !filename.ends_with(\".rb\") {\n        bail!(\"formula filename does not end in .rb: {filename}\");\n    }\n\n    let token = read_token(&args.token_env, args.dry_run)?;\n    // For HTTPS tap URLs, build an `http.extraHeader` config knob carrying\n    // Basic auth credentials. Non-HTTPS URLs (file://, ssh) carry their\n    // own auth.\n    let auth_args = build_auth_args(&args.tap_repo, token.as_deref());\n\n    let work = TempDir::new(\"dbt-ci-brew-publish\")?;","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-ci/src/homebrew/publish.rs#L25-L61","documentation":"`dbt-ci homebrew publish` verifies early in `run` that the `--formula` argument points at an existing file before attempting to publish a Homebrew formula. If the path does not exist or is a directory, the command aborts with `bail!(\"formula file not found: ...\")`. This is a fail-fast input validation to avoid publishing garbage or failing later in the pipeline.","triggerScenarios":"Running `dbt-ci homebrew publish` with a `--formula` path that (a) does not exist on disk, (b) is a directory rather than a file, or (c) contains a typo/relative path resolved from the wrong working directory.","commonSituations":"Typo in the formula filename; running the command from a different directory than expected so a relative path doesn't resolve; CI checkout missing the `.rb` formula; passing a directory (e.g., a `Formula/` folder) instead of the specific file.","solutions":["Verify the path passed to `--formula` exists: run `ls -l <path>` and correct any typo.","If using a relative path, run the command from the directory where the formula lives, or pass an absolute path.","Confirm the CI job actually checked out the repository containing the formula before running publish."],"exampleFix":"// before\ndbt-ci homebrew publish --formula Formula/dbt.rb  # run from wrong cwd\n// after\ndbt-ci homebrew publish --formula /abs/path/to/repo/Formula/dbt.rb","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn validate_formula_path(p: &Path) -> Result<(), String> {\n    if !p.is_file() {\n        return Err(format!(\"formula file not found: {}\", p.display()));\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match publish(args) {\n    Err(e) if e.to_string().contains(\"formula file not found\") => {\n        eprintln!(\"Check --formula path: {} (cwd: {:?})\", args.formula.display(), std::env::current_dir());\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Always pass an absolute path to --formula in CI scripts.","Add a preflight `test -f \"$FORMULA\"` step before invoking dbt-ci homebrew publish.","Verify the CI job checks out the repo containing the Formula/ directory."],"tags":["cli","file-not-found","homebrew","validation"],"backgroundTag":"file-not-found","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}