nikivdev/code · error
--path cannot be used with --no-commit or --hash
Error message
--path cannot be used with --no-commit or --hash
What it means
The `f pr`/commit command rejects mutually exclusive options up front: `--path` (commit only selected paths) combined with `--no-commit` (skip committing) or `--hash` (operate on an existing commit). These modes are contradictory - selecting paths implies creating a commit, while the other two imply not creating one - so the CLI bails before doing any work.
Source
Thrown at src/commit.rs:9566
return run_pr_feedback(&repo_root, feedback);
}
ensure_git_repo()?;
let repo_root = git_root_or_cwd();
ensure_commit_setup(&repo_root)?;
match args.as_slice() {
// Convenience: `f pr open` opens the PR for the current branch (or queued commit) without
// creating a new commit.
[a] if a == "open" => return run_pr_open(&repo_root, &opts),
// Convenience: `f pr open edit` opens a local markdown file in Zed and syncs PR
// title/body on save.
[a, b] if a == "open" && b == "edit" => return run_pr_open_edit(&repo_root, &opts),
_ => {}
}
if !opts.paths.is_empty() && (opts.no_commit || opts.hash.is_some()) {
bail!("--path cannot be used with --no-commit or --hash");
}
let should_commit = !opts.no_commit && opts.hash.is_none();
if should_commit {
let queue = resolve_commit_queue_mode(true, false);
let review_selection = resolve_review_selection_v2(false, None);
let message = if args.is_empty() {
None
} else {
Some(args.join(" "))
};
run_with_check_sync(
true,
false,
review_selection,
message.as_deref(),
1000,
false,View on GitHub (pinned to a747e741ae)
Solutions
- Remove `--no-commit` if you actually want to commit the selected paths.
- Remove `--hash` if you want to commit paths instead of operating on an existing commit.
- Drop `--path` if you only meant to skip committing or target an existing hash.
- Run the command's help (`f pr --help`) to confirm the intended flag combination.
Example fix
// before f pr "msg" --path src/foo.rs --no-commit // after f pr "msg" --path src/foo.rs # or drop --path if using --no-commit/--hash
Defensive patterns
Strategy: validation
Validate before calling
const KNOWN = new Set(["--show-full", "--todos", "--no-todos"]);
// validate mode flags before invoking:
if (args.includes("--path") && (args.includes("--no-commit") || args.includes("--hash"))) {
throw new Error("--path cannot be combined with --no-commit or --hash");
} Try / catch
try { await run(args); }
catch (e) {
if (String(e).includes("--path cannot be used")) fixFlagCombination(args);
else throw e;
} Prevention
- Read `--help` before mixing mode flags.
- Keep one invocation = one mode (paths-commit, no-commit, or hash).
- Validate flag combos in wrapper scripts before invoking the CLI.
When it happens
Trigger: Invoking the command with `--path <p>` together with `--no-commit`, or `--path <p>` together with `--hash <sha>`; typically a scripted or copy-pasted command mixing flags from two different usage modes.
Common situations: Reusing a command template and appending `--path` for partial staging; automations that always pass `--hash` and were extended with `--path`; typo/misremembered flag semantics.
Related errors
- sessions requires a specific provider (claude or codex)
- continue requires a specific provider (claude or codex)
- --all cannot be combined with HASH. Use `f commit-queue appr
- unknown `f pr feedback` option: {token}
- multiple PR selectors provided. Use exactly one selector.
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/2463241b82b78d99.
Report an issue: GitHub.