Skip to content

Commit 9780f8c

Browse files
committed
feat: Make it the default behavior
1 parent 5b2d0b0 commit 9780f8c

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

src/bin/cargo/commands/install.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ pub fn cli() -> App {
2424
))
2525
.arg_jobs()
2626
.arg(opt("force", "Force overwriting existing crates or binaries").short("f"))
27-
.arg(
28-
opt(
29-
"ensure",
30-
"If you already have a suitable version, simply leaves it as-is.",
31-
)
32-
.short("e"),
33-
)
3427
.arg_features()
3528
.arg(opt("debug", "Build in debug mode instead of release mode"))
3629
.arg_targets_bins_examples(
@@ -135,7 +128,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
135128
version,
136129
&compile_opts,
137130
args.is_present("force"),
138-
args.is_present("ensure"),
139131
)?;
140132
}
141133
Ok(())

src/cargo/ops/cargo_install.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ pub fn install(
4242
vers: Option<&str>,
4343
opts: &ops::CompileOptions<'_>,
4444
force: bool,
45-
ensure: bool,
4645
) -> CargoResult<()> {
4746
let root = resolve_root(root, opts.config)?;
4847
let map = SourceConfigMap::new(opts.config)?;
@@ -57,7 +56,6 @@ pub fn install(
5756
vers,
5857
opts,
5958
force,
60-
ensure,
6159
true,
6260
)?;
6361
(true, false)
@@ -77,7 +75,6 @@ pub fn install(
7775
vers,
7876
opts,
7977
force,
80-
ensure,
8178
first,
8279
) {
8380
Ok(()) => succeeded.push(krate),
@@ -140,7 +137,6 @@ fn install_one(
140137
vers: Option<&str>,
141138
opts: &ops::CompileOptions<'_>,
142139
force: bool,
143-
ensure: bool,
144140
is_first_install: bool,
145141
) -> CargoResult<()> {
146142
let config = opts.config;
@@ -252,7 +248,7 @@ fn install_one(
252248
let metadata = metadata(config, root)?;
253249
let list = read_crate_list(&metadata)?;
254250
let dst = metadata.parent().join("bin");
255-
check_overwrites(&dst, pkg, &opts.filter, &list, force, ensure)?;
251+
check_overwrites(&dst, pkg, &opts.filter, &list, force)?;
256252
}
257253

258254
let exec: Arc<dyn Executor> = Arc::new(DefaultExecutor);
@@ -291,7 +287,7 @@ fn install_one(
291287
let metadata = metadata(config, root)?;
292288
let mut list = read_crate_list(&metadata)?;
293289
let dst = metadata.parent().join("bin");
294-
let duplicates = check_overwrites(&dst, pkg, &opts.filter, &list, force, ensure)?;
290+
let duplicates = check_overwrites(&dst, pkg, &opts.filter, &list, force)?;
295291

296292
fs::create_dir_all(&dst)?;
297293

@@ -415,7 +411,6 @@ fn check_overwrites(
415411
filter: &ops::CompileFilter,
416412
prev: &CrateListingV1,
417413
force: bool,
418-
ensure: bool,
419414
) -> CargoResult<BTreeMap<String, Option<PackageId>>> {
420415
// If explicit --bin or --example flags were passed then those'll
421416
// get checked during cargo_compile, we only care about the "build
@@ -431,28 +426,23 @@ fn check_overwrites(
431426

432427
let msg = check_overwrites_format_error_message(&duplicates);
433428

434-
if ensure {
435-
let is_installed_old = duplicates
436-
.iter()
437-
.filter(|(_, v)| v.is_some())
438-
.all(|(_, v)| v.unwrap().version() < pkg.version());
439-
440-
if is_installed_old {
441-
return Ok(duplicates);
442-
}
429+
let is_installed_old = duplicates
430+
.iter()
431+
.filter(|(_, v)| v.is_some())
432+
.all(|(_, v)| v.unwrap().version() < pkg.version());
443433

444-
eprintln!("{}", msg);
445-
std::process::exit(0)
434+
if is_installed_old {
435+
return Ok(duplicates);
446436
}
447437

448-
Err(failure::format_err!("{}", msg))
438+
eprintln!("{}", msg);
439+
std::process::exit(0)
449440
}
450441

451442
fn check_overwrites_format_error_message(
452443
duplicates: &BTreeMap<String, Option<PackageId>>,
453444
) -> String {
454445
let mut msg = String::new();
455-
456446
for (bin, p) in duplicates.iter() {
457447
msg.push_str(&format!("binary `{}` already exists in destination", bin));
458448
if let Some(p) = p.as_ref() {

0 commit comments

Comments
 (0)