diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index c8764421db6a4..daf02811e8198 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -2536,11 +2536,6 @@ pub struct SyncArgs { #[arg(long, overrides_with("dev"))] pub no_dev: bool, - // /// Omit non-development dependencies. - // /// - // /// The project itself will also be omitted. - // #[arg(long, conflicts_with("no_dev"))] - // pub only_dev: bool, /// Do not remove extraneous packages present in the environment. /// /// When enabled, uv will make the minimum necessary changes to satisfy the requirements. diff --git a/crates/uv-configuration/src/install_options.rs b/crates/uv-configuration/src/install_options.rs index 63e400a75ad94..0de0f411eca00 100644 --- a/crates/uv-configuration/src/install_options.rs +++ b/crates/uv-configuration/src/install_options.rs @@ -34,25 +34,41 @@ impl InstallOptions { project_name: Option<&PackageName>, members: &BTreeSet, ) -> bool { - // If `--no-install-project` is set, remove the project itself. The project is always - // part of the workspace. - if self.no_install_project || self.no_install_workspace { + // If `--no-install-project` is set, remove the project itself. + if self.no_install_project { if let Some(project_name) = project_name { if package == project_name { + debug!("Omitting `{package}` from resolution due to `--no-install-project`"); return false; } - } else { - debug!("Ignoring `--no-install-project` for virtual workspace"); - }; + } } // If `--no-install-workspace` is set, remove the project and any workspace members. - if self.no_install_workspace && members.contains(package) { - return false; + if self.no_install_workspace { + // In some cases, the project root might be omitted from the list of workspace members + // encoded in the lockfile. (But we already checked this above if `--no-install-project` + // is set.) + if !self.no_install_project { + if let Some(project_name) = project_name { + if package == project_name { + debug!( + "Omitting `{package}` from resolution due to `--no-install-workspace`" + ); + return false; + } + } + } + + if members.contains(package) { + debug!("Omitting `{package}` from resolution due to `--no-install-workspace`"); + return false; + } } // If `--no-install-package` is provided, remove the requested packages. if self.no_install_package.contains(package) { + debug!("Omitting `{package}` from resolution due to `--no-install-package`"); return false; }