Skip to content

Commit 2b7088c

Browse files
committed
add --without-cargo flag to change default cargo install behavior
1 parent c5e86ee commit 2b7088c

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ struct Opts {
151151
parse(from_os_str)
152152
)]
153153
script: Option<PathBuf>,
154+
155+
#[structopt(
156+
long = "without-cargo",
157+
help = "Do not install cargo [default: install cargo]"
158+
)]
159+
without_cargo: bool,
154160
}
155161

156162
pub type GitDate = Date<Utc>;

src/toolchains.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,21 @@ impl Toolchain {
231231
.map_err(InstallError::Download)?;
232232
}
233233

234-
// download nightly cargo by default
235-
// this behavior was changed from an
236-
// optional feature with the `--with-cargo`
237-
// flag as of v0.6.0
234+
// download cargo by default
235+
// deactivate with the `--without-cargo` flag
236+
// this default behavior was changed as of v0.6.0
238237
// see: https://github.com/rust-lang/cargo-bisect-rustc/issues/81
239-
let filename = format!("cargo-nightly-{}", self.host);
240-
download_tarball(
241-
&client,
242-
&format!("cargo for {}", self.host),
243-
&format!("{}/{}/{}.tar", dl_params.url_prefix, location, filename,),
244-
Some(&PathBuf::from(&filename).join("cargo")),
245-
tmpdir.path(),
246-
)
247-
.map_err(InstallError::Download)?;
238+
if !dl_params.without_cargo {
239+
let filename = format!("cargo-nightly-{}", self.host);
240+
download_tarball(
241+
&client,
242+
&format!("cargo for {}", self.host),
243+
&format!("{}/{}/{}.tar", dl_params.url_prefix, location, filename,),
244+
Some(&PathBuf::from(&filename).join("cargo")),
245+
tmpdir.path(),
246+
)
247+
.map_err(InstallError::Download)?;
248+
}
248249

249250
if dl_params.install_src {
250251
let filename = "rust-src-nightly";
@@ -411,6 +412,7 @@ pub(crate) struct DownloadParams {
411412
tmp_dir: PathBuf,
412413
install_dir: PathBuf,
413414
install_src: bool,
415+
without_cargo: bool,
414416
force_install: bool,
415417
}
416418

@@ -435,6 +437,7 @@ impl DownloadParams {
435437
tmp_dir: cfg.rustup_tmp_path.clone(),
436438
install_dir: cfg.toolchains_path.clone(),
437439
install_src: cfg.args.with_src,
440+
without_cargo: cfg.args.without_cargo,
438441
force_install: cfg.args.force_install,
439442
}
440443
}

0 commit comments

Comments
 (0)