astral-sh/uv · error · anyhow::Error

pip-compile's `--reuse-hashes` is unsupported (uv doesn't re

Error message

pip-compile's `--reuse-hashes` is unsupported (uv doesn't reuse hashes)

What it means

uv accepts pip-tools' CLI flags as hidden compatibility args for `uv pip compile`. `PipCompileCompatArgs::validate()` classifies each flag: flags uv can honor silently are warned about, flags whose semantics uv cannot reproduce return an error. `--reuse-hashes` tells pip-compile to reuse hashes from an existing output file; uv re-resolves and re-fetches hashes every run, so it is rejected rather than silently ignored.

Source

Thrown at crates/uv-cli/src/compat.rs:80

    ///
    /// This method will warn when an argument is passed that has no effect but matches uv's
    /// behavior. If an argument is passed that does _not_ match uv's behavior (e.g.,
    /// `--no-build-isolation`), this method will return an error.
    fn validate(&self) -> Result<()> {
        if self.allow_unsafe {
            warn_user!(
                "pip-compile's `--allow-unsafe` has no effect (uv can safely pin `pip` and other packages)"
            );
        }

        if self.no_allow_unsafe {
            warn_user!(
                "pip-compile's `--no-allow-unsafe` has no effect (uv can safely pin `pip` and other packages)"
            );
        }

        if self.reuse_hashes {
            return Err(anyhow!(
                "pip-compile's `--reuse-hashes` is unsupported (uv doesn't reuse hashes)"
            ));
        }

        if self.no_reuse_hashes {
            warn_user!("pip-compile's `--no-reuse-hashes` has no effect (uv doesn't reuse hashes)");
        }

        if let Some(resolver) = self.resolver {
            match resolver {
                Resolver::Backtracking => {
                    warn_user!(
                        "pip-compile's `--resolver=backtracking` has no effect (uv always backtracks)"
                    );
                }
                Resolver::Legacy => {
                    return Err(anyhow!(
                        "pip-compile's `--resolver=legacy` is unsupported (uv always backtracks)"

View on GitHub (pinned to f1a42680ff)

Solutions

  1. Remove `--reuse-hashes` from the invocation; uv always re-resolves and emits fresh hashes.
  2. If you wanted cache speedups, rely on uv's cache (it is already fast) instead of hash reuse.
  3. Audit migrated scripts for other pip-tools flags and drop the ones uv rejects (`--resolver=legacy`, `--max-rounds`, `--config`, `--pip-args`, `--client-cert`, `--emit-trusted-host`, `--emit-options`).

Example fix

# before
uv pip compile --reuse-hashes requirements.in

# after
uv pip compile requirements.in
Defensive patterns

Strategy: validation

Validate before calling

UNSUPPORTED_COMPILE_FLAGS = {
    "--reuse-hashes", "--resolver=legacy", "--max-rounds", "--client-cert",
    "--emit-trusted-host", "--config", "--emit-options", "--pip-args",
}

def check_uv_compile_args(argv: list[str]) -> None:
    bad = [a for a in argv if a.split("=", 1)[0] in UNSUPPORTED_COMPILE_FLAGS]
    if bad:
        raise ValueError(f"uv pip compile rejects pip-compile flags: {bad}")

Try / catch

# when shelling out to uv from tooling
proc = subprocess.run(["uv", "pip", "compile", *args], capture_output=True, text=True)
if proc.returncode != 0 and "unsupported" in proc.stderr:
    flag = next((a for a in args if a in UNSUPPORTED_COMPILE_FLAGS), None)
    if flag:
        args = [a for a in args if a != flag]  # drop the rejected flag, surface to user
        raise RuntimeError(f"dropped unsupported flag {flag}; rerun without it")

Prevention

When it happens

Trigger: Running `uv pip compile --reuse-hashes requirements.in` (or a wrapper/Makefile/CI job migrated from pip-compile that still passes the flag). `validate()` runs before any resolution work and the process exits with this message.

Common situations: Teams switching incremental pip-compile workflows to `uv pip compile` and copying the old flag set; renv-like lockfile refresh scripts that pass `--reuse-hashes` to speed up runs; wrapper tools invoking uv with the same argv they used for pip-compile.

Related errors


AI-assisted analysis of astral-sh/uv@f1a42680ff (2026-08-16). Data as JSON: /api/errors/a365c1bcfc076b3f. Report an issue: GitHub.