Skip to content

Commit 91e0377

Browse files
Merge #554
554: Add `--force-non-host` flag. r=Emilgardis a=reitermarkus Closes #536. Co-authored-by: Alex Huszagh <[email protected]>
2 parents 5c96126 + 3665634 commit 91e0377

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

.changes/554.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "fixed",
3+
"description": "add the `--force-non-host` flag for newer rustup versions",
4+
"issues": [536]
5+
}

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ directories = "4.0.1"
4646
walkdir = { version = "2", optional = true }
4747
tempfile = "3.3.0"
4848
owo-colors = { version = "3.4.0", features = ["supports-colors"] }
49+
semver = "1"
4950

5051
[target.'cfg(not(windows))'.dependencies]
5152
nix = { version = "0.24", default-features = false, features = ["user"] }

src/rustup.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,31 @@ cross will not attempt to configure the toolchain further so that it can run you
130130
})
131131
}
132132

133+
fn version(msg_info: &mut MessageInfo) -> Result<Version> {
134+
let out = rustup_command(msg_info, false)
135+
.arg("--version")
136+
.run_and_get_stdout(msg_info)?;
137+
138+
match out
139+
.lines()
140+
.next()
141+
.and_then(|line| line.split_whitespace().nth(1))
142+
{
143+
Some(version) => {
144+
semver::Version::parse(version).wrap_err_with(|| "failed to parse rustup version")
145+
}
146+
None => eyre::bail!("failed to get rustup version"),
147+
}
148+
}
149+
133150
pub fn install_toolchain(toolchain: &QualifiedToolchain, msg_info: &mut MessageInfo) -> Result<()> {
151+
let mut command = rustup_command(msg_info, false);
134152
let toolchain = toolchain.to_string();
135-
rustup_command(msg_info, false)
136-
.args(&["toolchain", "add", &toolchain, "--profile", "minimal"])
153+
command.args(&["toolchain", "add", &toolchain, "--profile", "minimal"]);
154+
if version(msg_info)? >= semver::Version::new(1, 25, 0) {
155+
command.arg("--force-non-host");
156+
}
157+
command
137158
.run(msg_info, false)
138159
.wrap_err_with(|| format!("couldn't install toolchain `{toolchain}`"))
139160
}

0 commit comments

Comments
 (0)