Skip to content

Commit 561beb2

Browse files
committed
Auto merge of #5606 - vramana:fix/cargo-install, r=alexcrichton
`cargo install` will ignore the target triple specified in a project directory Fixes #5441
2 parents e511e15 + 1bad991 commit 561beb2

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/bin/cargo/commands/install.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ continuous integration systems.",
7474
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
7575
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
7676
compile_opts.build_config.release = !args.is_present("debug");
77+
// We override target architecture to host architecture since it may be
78+
// set to some other architecture in .cargo/config.
79+
compile_opts.build_config.requested_target = None;
7780

7881
let krates = args.values_of("crate")
7982
.unwrap_or_default()

tests/testsuite/install.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,3 +1606,35 @@ fn git_repo_replace() {
16061606
.contains(&format!("{}", new_rev))
16071607
);
16081608
}
1609+
1610+
#[test]
1611+
fn install_with_non_existent_target() {
1612+
pkg("bar", "0.0.1");
1613+
1614+
let p = project("foo")
1615+
.file(
1616+
"Cargo.toml",
1617+
r#"
1618+
[package]
1619+
name = "foo"
1620+
version = "0.1.0"
1621+
authors = []
1622+
"#,
1623+
)
1624+
.file(
1625+
".cargo/config",
1626+
r#"
1627+
[build]
1628+
target = "non-existing-target"
1629+
"#,
1630+
)
1631+
.file("src/main.rs", "fn main() {}")
1632+
.build();
1633+
1634+
assert_that(
1635+
cargo_process("install").arg("bar").cwd(p.root()),
1636+
execs().with_status(0),
1637+
);
1638+
assert_that(cargo_home(), has_installed_exe("bar"));
1639+
}
1640+

0 commit comments

Comments
 (0)