Skip to content

Commit

Permalink
Work around spurious "failed to select a version" error
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Aug 28, 2023
1 parent 26676e2 commit ea4c475
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Work around spurious "failed to select a version" error when `--version-range` option is used.

## [0.6.1] - 2023-08-28

- Fix bug in `--no-private` flag.
Expand Down
23 changes: 23 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,32 @@ fn try_main() -> Result<()> {
line.run_with_output()?;
}

let mut regenerate_lockfile_on_51_or_up = false;
range.iter().enumerate().try_for_each(|(i, (cargo_version, toolchain))| {
if i != 0 {
rustup::install_toolchain(toolchain, &cx.target, true)?;
if regenerate_lockfile_on_51_or_up && *cargo_version >= 51 {
let mut line = line.clone();
line.leading_arg(toolchain);
line.arg("generate-lockfile");
if let Some(pid) = cx.current_package() {
let package = cx.packages(pid);
if !cx.no_manifest_path {
line.arg("--manifest-path");
line.arg(
package
.manifest_path
.strip_prefix(&cx.current_dir)
.unwrap_or(&package.manifest_path),
);
}
}
line.run_with_output()?;
regenerate_lockfile_on_51_or_up = false;
}
}
if *cargo_version < 51 {
regenerate_lockfile_on_51_or_up = true;
}

if cx.clean_per_version {
Expand Down

0 comments on commit ea4c475

Please sign in to comment.