Skip to content

Commit

Permalink
cargo install will ignore the target triple specified in a project …
Browse files Browse the repository at this point in the history
…directory

Fixes rust-lang#5441
  • Loading branch information
vramana committed Jun 17, 2018
1 parent 92b5106 commit 1bad991
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ continuous integration systems.",
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
compile_opts.build_config.release = !args.is_present("debug");
// We override target architecture to host architecture since it may be
// set to some other architecture in .cargo/config.
compile_opts.build_config.requested_target = None;

let krates = args.values_of("crate")
.unwrap_or_default()
Expand Down
32 changes: 32 additions & 0 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,3 +1581,35 @@ fn git_repo_replace() {
.contains(&format!("{}", new_rev))
);
}

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

let p = project("foo")
.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();

assert_that(
cargo_process("install").arg("bar").cwd(p.root()),
execs().with_status(0),
);
assert_that(cargo_home(), has_installed_exe("bar"));
}

0 comments on commit 1bad991

Please sign in to comment.