Skip to content

Commit 2e34168

Browse files
committed
detect broken lock file
1 parent c196e61 commit 2e34168

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/prepare.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ fn run_command(cmd: Command) -> anyhow::Result<()> {
146146
let mut yanked_deps = false;
147147
let mut missing_deps = false;
148148
let mut broken_deps = false;
149+
let mut broken_lockfile = false;
149150

150151
let mut process = |line: &str, _: &mut ProcessLinesActions| {
151152
if line.contains("failed to select a version for the requirement") {
@@ -158,6 +159,8 @@ fn run_command(cmd: Command) -> anyhow::Result<()> {
158159
|| line.contains("error: invalid table header")
159160
{
160161
broken_deps = true;
162+
} else if line.contains("error: failed to parse lock file at") {
163+
broken_lockfile = true;
161164
}
162165
};
163166

@@ -172,6 +175,9 @@ fn run_command(cmd: Command) -> anyhow::Result<()> {
172175
Err(CommandError::ExecutionFailed { status: _, stderr }) if broken_deps => {
173176
Err(PrepareError::InvalidCargoTomlSyntaxInDependencies(stderr).into())
174177
}
178+
Err(CommandError::ExecutionFailed { status: _, stderr }) if broken_lockfile => {
179+
Err(PrepareError::InvalidCargoLock(stderr).into())
180+
}
175181
Err(err) => Err(err.into()),
176182
}
177183
}
@@ -391,6 +397,8 @@ pub enum PrepareError {
391397
/// Some of the dependencies do not exist anymore.
392398
#[error("the crate depends on missing dependencies: \n\n{0}")]
393399
MissingDependencies(String),
400+
#[error("the crate has a broken lockfile: \n\n{0}")]
401+
InvalidCargoLock(String),
394402
}
395403

396404
#[cfg(test)]

0 commit comments

Comments
 (0)