Skip to content

Commit

Permalink
fix: mise install rust failed on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
roele committed Jan 7, 2025
1 parent e93bc80 commit 69b094c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e-win/go.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Describe 'node' {
Describe 'go' {
It 'executes go 1.23.3' {
mise x go@1.23.3 -- where go
mise x go@1.23.3 -- go version | Should -BeLike "go version go1.23.3 windows/*"
Expand Down
2 changes: 1 addition & 1 deletion e2e-win/python.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Describe 'node' {
Describe 'python' {
It 'executes python 3.12.0' {
mise x python@3.12.0 -- where python
mise x python@3.12.0 -- python --version | Should -Be "Python 3.12.0"
Expand Down
2 changes: 1 addition & 1 deletion e2e-win/rust.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Describe 'node' {
Describe 'rust' {
It 'executes rust 1.82.0' {
mise x rust@1.82.0 -- rustc -V | Should -BeLike "rustc 1.82.0*"
}
Expand Down
13 changes: 12 additions & 1 deletion src/plugins/core/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl RustPlugin {
return Ok(());
}
ctx.pr.set_message("Downloading rustup-init".into());
HTTP.download_file("https://sh.rustup.rs", &rustup_path(), Some(&ctx.pr))?;
HTTP.download_file(&rustup_url(), &rustup_path(), Some(&ctx.pr))?;
file::make_executable(rustup_path())?;
file::create_dir_all(rustup_home())?;
let cmd = CmdLineRunner::new(rustup_path())
Expand Down Expand Up @@ -203,6 +203,17 @@ const CARGO_BIN: &str = "cargo";
#[cfg(windows)]
const CARGO_BIN: &str = "cargo.exe";

#[cfg(unix)]
fn rustup_url() -> String {
"https://sh.rustup.rs".to_string()
}

#[cfg(windows)]
fn rustup_url() -> String {
let arch = &*SETTINGS.arch();
format!("https://win.rustup.rs/{arch}")
}

fn rustup_path() -> PathBuf {
dirs::CACHE.join("rust").join(RUSTUP_INIT_BIN)
}
Expand Down

0 comments on commit 69b094c

Please sign in to comment.