Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve error on parsing lockfile #1180

Merged
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
17 changes: 13 additions & 4 deletions src/lock_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod satisfiability;
mod update;

use crate::Project;
use miette::IntoDiagnostic;
use miette::{IntoDiagnostic, WrapErr};
use rattler_conda_types::RepoDataRecord;
use rattler_lock::{LockFile, PypiPackageData, PypiPackageEnvironmentData};

Expand All @@ -35,9 +35,18 @@ pub async fn load_lock_file(project: &Project) -> miette::Result<LockFile> {
let lock_file_path = project.lock_file_path();
if lock_file_path.is_file() {
// Spawn a background task because loading the file might be IO bound.
tokio::task::spawn_blocking(move || LockFile::from_path(&lock_file_path).into_diagnostic())
.await
.unwrap_or_else(|e| Err(e).into_diagnostic())
tokio::task::spawn_blocking(move || {
LockFile::from_path(&lock_file_path)
.into_diagnostic()
.wrap_err_with(|| {
format!(
"Failed to load lock file from `{}`",
lock_file_path.display()
)
})
})
.await
.unwrap_or_else(|e| Err(e).into_diagnostic())
} else {
Ok(LockFile::default())
}
Expand Down
Loading