diff --git a/src/docker.rs b/src/docker.rs index 3dbf6a962..5c41dc69c 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -32,6 +32,7 @@ pub struct RustEnv<'a> { pub rustup_home: (PathBuf, Perm), pub target_dir: (PathBuf, Perm), pub cap_lints: &'a ExCapLints, + pub enable_unstable_cargo_features: bool, } pub struct MountConfig<'a> { @@ -97,7 +98,7 @@ pub fn rust_container(config: RustEnv) -> ContainerConfig { }, ]; - let env = vec![ + let mut env = vec![ ("USER_ID", format!("{}", user_id())), ("CMD", config.args.join(" ")), ("CARGO_INCREMENTAL", "0".to_string()), @@ -107,6 +108,12 @@ pub fn rust_container(config: RustEnv) -> ContainerConfig { format!("--cap-lints={}", config.cap_lints.to_str()), ), ]; + if config.enable_unstable_cargo_features { + env.push(( + "__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", + "nightly".to_string(), + )); + } ContainerConfig { image_name: IMAGE_NAME, diff --git a/src/ex.rs b/src/ex.rs index 68f2a13c1..02db4b0e3 100644 --- a/src/ex.rs +++ b/src/ex.rs @@ -374,7 +374,12 @@ fn capture_lockfile_inner( path: &Path, toolchain: &Toolchain, ) -> Result<()> { - let args = &["generate-lockfile", "--manifest-path", "Cargo.toml"]; + let args = &[ + "generate-lockfile", + "--manifest-path", + "Cargo.toml", + "-Zno-index-update", + ]; toolchain .run_cargo(ex, path, args, CargoState::Unlocked, false) .chain_err(|| format!("unable to generate lockfile for {}", krate))?; diff --git a/src/toolchain.rs b/src/toolchain.rs index b8db4c667..0325d2f22 100644 --- a/src/toolchain.rs +++ b/src/toolchain.rs @@ -44,6 +44,8 @@ impl Toolchain { } } + self.prep_offline_registry()?; + Ok(()) } @@ -90,6 +92,10 @@ impl Toolchain { CargoState::Locked => docker::Perm::ReadOnly, CargoState::Unlocked => docker::Perm::ReadWrite, }; + + let enable_unstable_cargo_features = + !toolchain_name.starts_with("nightly-") && args.iter().any(|a| a.starts_with("-Z")); + let rust_env = docker::RustEnv { args: &full_args, work_dir: (source_dir.into(), perm), @@ -98,9 +104,27 @@ impl Toolchain { // This is configured as CARGO_TARGET_DIR by the docker container itself target_dir: (ex_target_dir, docker::Perm::ReadWrite), cap_lints: &ex.cap_lints, + enable_unstable_cargo_features, }; docker::run(&docker::rust_container(rust_env), quiet) } + + pub fn prep_offline_registry(&self) -> Result<()> { + // This nop cargo command is to update the registry + // so we don't have to do it for each crate. + let toolchain_arg = "+".to_string() + &self.rustup_name(); + let full_args = [&toolchain_arg, "search", "lazy_static"]; + RunCommand::new(&installed_binary("cargo"), &full_args) + .local_rustup() + .quiet(true) + .run() + .chain_err(|| { + format!( + "unable to update the index for toolchain {}", + &self.rustup_name() + ) + }) + } } impl ToString for Toolchain {