diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index c99ff3b418d09..6282017e4c17f 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -1836,8 +1836,6 @@ pub struct RunArgs { /// Run with all packages listed in the given `requirements.txt` files. /// /// Using `pyproject.toml`, `setup.py`, or `setup.cfg` files is not allowed. - /// - /// If `-` is provided, then requirements will be read from stdin. #[arg(long, value_parser = parse_maybe_file_path)] pub with_requirements: Vec>, diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index eb9f6d14a9437..bc072ee74051b 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use std::ffi::OsString; use std::fmt::Write; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use anyhow::{bail, Context, Result}; use itertools::Itertools; @@ -72,6 +72,9 @@ pub(crate) async fn run( RequirementsSource::SetupCfg(_) => { bail!("Adding requirements from a `setup.cfg` is not supported in `uv run`"); } + RequirementsSource::RequirementsTxt(path) => if path == Path::new("-") { + bail!("Reading requirements from stdin is not supported in `uv run`"); + } _ => {} } } diff --git a/crates/uv/tests/run.rs b/crates/uv/tests/run.rs index 8fe85598f1cf5..815d9866101b4 100644 --- a/crates/uv/tests/run.rs +++ b/crates/uv/tests/run.rs @@ -700,5 +700,21 @@ fn run_requirements_txt() -> Result<()> { + sniffio==1.3.1 "###); + // But reject `-` as a requirements file. + uv_snapshot!(context.filters(), context.run() + .arg("--with-requirements") + .arg("-") + .arg("--with") + .arg("iniconfig") + .arg("main.py"), @r###" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + warning: `uv run` is experimental and may change without warning + error: Reading requirements from stdin is not supported in `uv run` + "###); + Ok(()) }