Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Enable code.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Oct 2, 2023
1 parent 5966fab commit 8fd29f8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 34 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 0.3.0

#### 🚀 Updates

- Will now attempt to install `rustup` if it does not exist on the current machine.

#### 🐞 Fixes

- Will now respect the `RUSTUP_HOME` environment variable when locating the `.rustup` store.
Expand Down
62 changes: 28 additions & 34 deletions src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,39 +45,33 @@ pub fn native_install(

// Install rustup if it does not exist
if !command_exists(&env, "rustup") {
// host_log!("Installing rustup");

// NOTE: this won't work until proto v0.19.1, how to allow it otherwise???

// let is_windows = env.os.is_windows();
// let script_path = PathBuf::from("/proto/temp").join(if is_windows {
// "rustup-init.exe"
// } else {
// "rustup-init.sh"
// });

// if !script_path.exists() {
// fs::write(
// &script_path,
// fetch_url_text(if is_windows {
// "https://win.rustup.rs"
// } else {
// "https://sh.rustup.rs"
// })?,
// )?;
// }

// exec_command!(ExecCommandInput {
// command: script_path.to_string_lossy().to_string(),
// args: vec!["--default-toolchain".into(), "none".into(), "-y".into()],
// set_executable: true,
// stream: true,
// ..ExecCommandInput::default()
// });

return err!(
"proto requires `rustup` to be installed and available on PATH to use Rust. Please install it and try again."
);
host_log!("Installing rustup");

let is_windows = env.os.is_windows();
let script_path = PathBuf::from("/proto/temp").join(if is_windows {
"rustup-init.exe"
} else {
"rustup-init.sh"
});

if !script_path.exists() {
fs::write(
&script_path,
fetch_url_text(if is_windows {
"https://win.rustup.rs"
} else {
"https://sh.rustup.rs"
})?,
)?;
}

exec_command!(ExecCommandInput {
command: script_path.to_string_lossy().to_string(),
args: vec!["--default-toolchain".into(), "none".into(), "-y".into()],
set_executable: true,
stream: true,
..ExecCommandInput::default()
});
}

let channel = if input.context.version == "canary" {
Expand All @@ -88,7 +82,7 @@ pub fn native_install(

let triple = format!("{}-{}", channel, get_target_triple(&env, NAME)?);

host_log!("Installing target \"{}\" with rustup", triple);
host_log!("Installing target {} with rustup", triple);

// Install if not already installed
let installed_list = exec_command!(pipe, "rustup", ["toolchain", "list"]);
Expand Down

0 comments on commit 8fd29f8

Please sign in to comment.