Skip to content

make cargo install ignore .cargo/config #5874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}