diff --git a/forc-pkg/src/pkg.rs b/forc-pkg/src/pkg.rs index be841dfb7b7..609a0f01c72 100644 --- a/forc-pkg/src/pkg.rs +++ b/forc-pkg/src/pkg.rs @@ -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 { + // 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.", @@ -274,7 +279,6 @@ impl BuildPlan { } else { Some(e) }; - let plan = BuildPlan::new(manifest, sway_git_tag, offline)?; Ok(plan) })?;