Skip to content

Commit 78bae45

Browse files
committed
Auto merge of #5874 - japaric:revert-revert-gh5606, r=alexcrichton
make `cargo install` ignore .cargo/config closes #5850 r? @alexcrichton
2 parents aecaef3 + 942e367 commit 78bae45

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/bin/cargo/commands/install.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ continuous integration systems.",
7575

7676
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
7777
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
78+
79+
// for `cargo-install` we want to use what the user specified via `--target` and ignore what's
80+
// in `.cargo/config` and what the environment says
81+
compile_opts.build_config.requested_target = args.target();
82+
7883
compile_opts.build_config.release = !args.is_present("debug");
7984

8085
let krates = args.values_of("crate")

src/doc/src/reference/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ check-revoke = true # Indicates whether SSL certs are checked for revocation
100100
jobs = 1 # number of parallel jobs, defaults to # of CPUs
101101
rustc = "rustc" # the rust compiler tool
102102
rustdoc = "rustdoc" # the doc generator tool
103-
target = "triple" # build for the target triple
103+
target = "triple" # build for the target triple (ignored by `cargo install`)
104104
target-dir = "target" # path of where to place all generated artifacts
105105
rustflags = ["..", ".."] # custom flags to pass to all compiler invocations
106106
incremental = true # whether or not to enable incremental compilation

tests/testsuite/install.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,3 +1237,31 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina
12371237
",
12381238
).run();
12391239
}
1240+
1241+
#[test]
1242+
fn install_ignores_cargo_config() {
1243+
pkg("bar", "0.0.1");
1244+
1245+
let p = project()
1246+
.file(
1247+
"Cargo.toml",
1248+
r#"
1249+
[package]
1250+
name = "foo"
1251+
version = "0.1.0"
1252+
authors = []
1253+
"#,
1254+
)
1255+
.file(
1256+
".cargo/config",
1257+
r#"
1258+
[build]
1259+
target = "non-existing-target"
1260+
"#,
1261+
)
1262+
.file("src/main.rs", "fn main() {}")
1263+
.build();
1264+
1265+
cargo_process("install bar").cwd(p.root()).with_status(0).run();
1266+
assert_has_installed_exe(cargo_home(), "bar");
1267+
}

0 commit comments

Comments
 (0)