Skip to content

Commit

Permalink
Auto merge of #5874 - japaric:revert-revert-gh5606, r=alexcrichton
Browse files Browse the repository at this point in the history
make `cargo install` ignore .cargo/config

closes #5850

r? @alexcrichton
  • Loading branch information
bors committed Sep 2, 2018
2 parents aecaef3 + 942e367 commit 78bae45
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ continuous integration systems.",

pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;

// for `cargo-install` we want to use what the user specified via `--target` and ignore what's
// in `.cargo/config` and what the environment says
compile_opts.build_config.requested_target = args.target();

compile_opts.build_config.release = !args.is_present("debug");

let krates = args.values_of("crate")
Expand Down
2 changes: 1 addition & 1 deletion src/doc/src/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ check-revoke = true # Indicates whether SSL certs are checked for revocation
jobs = 1 # number of parallel jobs, defaults to # of CPUs
rustc = "rustc" # the rust compiler tool
rustdoc = "rustdoc" # the doc generator tool
target = "triple" # build for the target triple
target = "triple" # build for the target triple (ignored by `cargo install`)
target-dir = "target" # path of where to place all generated artifacts
rustflags = ["..", ".."] # custom flags to pass to all compiler invocations
incremental = true # whether or not to enable incremental compilation
Expand Down
28 changes: 28 additions & 0 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,3 +1237,31 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina
",
).run();
}

#[test]
fn install_ignores_cargo_config() {
pkg("bar", "0.0.1");

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
authors = []
"#,
)
.file(
".cargo/config",
r#"
[build]
target = "non-existing-target"
"#,
)
.file("src/main.rs", "fn main() {}")
.build();

cargo_process("install bar").cwd(p.root()).with_status(0).run();
assert_has_installed_exe(cargo_home(), "bar");
}

0 comments on commit 78bae45

Please sign in to comment.