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: Failing BuildPlan generation with --locked does not return the cause of the error #2085

Closed
Closed
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
6 changes: 5 additions & 1 deletion forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ impl BuildPlan {
// If there are errors we will need to create the BuildPlan from scratch, i.e fetch & pin everything
let mut new_lock_cause = None;
let mut plan = plan_result.or_else(|e| -> Result<BuildPlan> {
// In the event of an unsuccessfull attempt of creating a BuildPlan while the user
// provided `--locked`, we should be printing the error instead of complaining about
// lack of lock file (if that is the case). So try to create the BuildPlan first
// then check if `--locked` is provided.
let plan = BuildPlan::new(manifest, sway_git_tag, offline)?;
if locked {
bail!(
"The lock file {} needs to be updated but --locked was passed to prevent this.",
Expand All @@ -274,7 +279,6 @@ impl BuildPlan {
} else {
Some(e)
};
let plan = BuildPlan::new(manifest, sway_git_tag, offline)?;
Ok(plan)
})?;

Expand Down