Skip to content

Commit

Permalink
fix: add check error message to remove uv dependencies (#3052)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim de Jager <[email protected]>
  • Loading branch information
Dozie2001 and tdejager authored Feb 5, 2025
1 parent 4abcfd8 commit 0e043c0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/cli/remove.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use clap::Parser;
use miette::Context;
use pixi_manifest::FeaturesExt;

use crate::environment::get_update_lock_file_and_prefix;
use crate::Project;
Expand Down Expand Up @@ -40,6 +41,26 @@ pub async fn execute(args: Args) -> miette::Result<()> {
.with_cli_config(prefix_update_config.config.clone());
let dependency_type = dependency_config.dependency_type();

// Prevent removing Python if PyPI dependencies exist
if let DependencyType::CondaDependency(_) = dependency_type {
for name in dependency_config.specs()?.keys() {
if name.as_source() == "python" {
// Check if there are any PyPI dependencies by importing the PypiDependencies trait
let pypi_deps = project.default_environment().pypi_dependencies(None);
if !pypi_deps.is_empty() {
let deps_list = pypi_deps
.iter()
.map(|(name, _)| name.as_source())
.collect::<Vec<_>>()
.join(", ");
return Err(miette::miette!(
"Cannot remove Python while PyPI dependencies exist. Please remove these PyPI dependencies first: {}",
deps_list
));
}
}
}
}
match dependency_type {
DependencyType::PypiDependency => {
for name in dependency_config.pypi_deps(&project)?.keys() {
Expand Down

0 comments on commit 0e043c0

Please sign in to comment.