Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/pixi/tests/integration_rust/source_package_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2899,8 +2899,8 @@ async fn verify_locked(pixi: &PixiControl) -> miette::Result<()> {
..UpdateLockFileOptions::default()
},
)
.await
.map(|_| ())
.await?;
Ok(())
}

/// `--locked` must succeed without touching the lock file.
Expand Down
4 changes: 2 additions & 2 deletions crates/pixi_api/src/workspace/add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub async fn add_conda_dep(
}
Err(e) => {
workspace.revert().await.into_diagnostic()?;
return Err(e);
return Err(e.into());
}
};

Expand Down Expand Up @@ -175,7 +175,7 @@ pub async fn add_pypi_dep(
}
Err(e) => {
workspace.revert().await.into_diagnostic()?;
return Err(e);
return Err(e.into());
}
};

Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_cli/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
// Scoped so the bars are cleared before the diff or the JSON is printed.
let updated_lock_file = {
let _clear_progress = pixi_reporters::TopLevelProgress::clear_when_done(Some(&progress));
UpdateContext::builder(&workspace, dispatcher)?
UpdateContext::builder(&workspace, dispatcher)
.with_lock_file(relaxed_lock_file.clone())
.with_no_install(args.no_install)
.with_update_targets(specs.packages.clone())
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_cli/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
.workspace()
.command_dispatcher_builder(Some(&progress))?
.finish();
let derived = UpdateContext::builder(workspace.workspace(), dispatcher)?
let derived = UpdateContext::builder(workspace.workspace(), dispatcher)
.with_lock_file(original_lock_file.clone())
.with_no_install(args.no_install_config.no_install || args.dry_run)
.finish()
Expand Down
51 changes: 40 additions & 11 deletions crates/pixi_core/src/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use pixi_consts::consts;
use pixi_git::credentials::store_credentials_from_url;
pub use pixi_install_pypi::{ContinuePyPIPrefixUpdate, on_python_interpreter_change};
use pixi_manifest::{
FeaturesExt, PixiPlatform, PixiPlatformName,
EnvironmentName, FeaturesExt, PixiPlatform, PixiPlatformName,
platform::{VirtualPackageRecords, candidate_subdirs},
};
use pixi_progress::await_in_progress;
Expand Down Expand Up @@ -42,8 +42,8 @@ use crate::workspace;
use crate::{
Workspace,
lock_file::{
LockFileDerivedData, ReinstallPackages, UpdateLockFileOptions, UpdateMode,
resolve_lock_platform_for,
LockFileDerivedData, ReinstallPackages, UpdateLockFileError, UpdateLockFileOptions,
UpdateMode, UpdatePrefixError, resolve_lock_platform_for,
},
workspace::{Environment, HasWorkspaceRef, grouped_environment::GroupedEnvironment},
};
Expand Down Expand Up @@ -882,7 +882,7 @@ pub async fn get_update_lock_file_and_prefix<'env>(
update_lock_file_options: UpdateLockFileOptions,
reinstall_packages: ReinstallPackages,
filter: &InstallFilter,
) -> miette::Result<(LockFileDerivedData<'env>, Prefix)> {
) -> Result<(LockFileDerivedData<'env>, Prefix), LockFileAndPrefixesError> {
let (lock_file, prefixes) = get_lock_file_and_prefixes(
std::slice::from_ref(environment),
None,
Expand All @@ -902,6 +902,36 @@ pub async fn get_update_lock_file_and_prefix<'env>(
))
}

/// An error that can occur while updating the lock file and the prefixes of
/// a set of environments.
#[derive(Debug, Error, Diagnostic)]
pub enum LockFileAndPrefixesError {
#[error(transparent)]
#[diagnostic(transparent)]
HostProbe(#[from] crate::host::HostProbeError),

#[error("no environments provided to install")]
NoEnvironments,

#[error("platform '{platform}' is not part of environment '{environment}'")]
PlatformNotInEnvironment {
platform: PixiPlatformName,
environment: EnvironmentName,
},

#[error(transparent)]
#[diagnostic(transparent)]
SanityCheck(#[from] SanityCheckError),

#[error(transparent)]
#[diagnostic(transparent)]
UpdateLockFile(#[from] UpdateLockFileError),

#[error(transparent)]
#[diagnostic(transparent)]
UpdatePrefix(#[from] UpdatePrefixError),
}

/// Chooses how installation obtains lock data.
pub enum LockFileSource {
/// Updates the workspace's persistent lock file.
Expand All @@ -926,9 +956,9 @@ pub async fn get_lock_file_and_prefixes<'env>(
lock_file_source: LockFileSource,
reinstall_packages: ReinstallPackages,
filter: &InstallFilter,
) -> miette::Result<(LockFileDerivedData<'env>, Vec<Prefix>)> {
) -> Result<(LockFileDerivedData<'env>, Vec<Prefix>), LockFileAndPrefixesError> {
if environments.is_empty() {
return Err(miette::miette!("No environments provided to install."));
return Err(LockFileAndPrefixesError::NoEnvironments);
}

let workspace = environments[0].workspace();
Expand All @@ -948,11 +978,10 @@ pub async fn get_lock_file_and_prefixes<'env>(
.is_none()
&& let Some(name) = target_platform
{
return Err(miette::miette!(
"platform '{}' is not part of environment '{}'",
name,
env.name(),
));
return Err(LockFileAndPrefixesError::PlatformNotInEnvironment {
platform: name.clone(),
environment: env.name().clone(),
});
}
if !no_install {
env.emit_emulation_warning();
Expand Down
5 changes: 3 additions & 2 deletions crates/pixi_core/src/lock_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ pub use satisfiability::{
};
pub use update::{
LoadLockFileError, LockFileDerivedData, LockFileVersionMismatchError, PackageFilterNames,
ReinstallEnvironment, ReinstallPackages, SolveCondaEnvironmentError, UpdateContext,
UpdateLockFileOptions, UpdateMode, UpdatePrefixError, UpdatedPrefix, WriteLockFileError,
ReinstallEnvironment, ReinstallPackages, SolveCondaEnvironmentError,
UnsupportedPypiPlatformError, UpdateContext, UpdateLockFileError, UpdateLockFileOptions,
UpdateMode, UpdatePrefixError, UpdatedPrefix, WriteLockFileError,
};
pub use utils::{LockedPackageKind, filter_lock_file};

Expand Down
Loading
Loading