Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI should not depend on rustup #1996

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

CLI should not depend on rustup #1996

wants to merge 5 commits into from

Conversation

mamcx
Copy link
Contributor

@mamcx mamcx commented Nov 14, 2024

Description of Changes

Rustup could not be installed (for example, for people who use nix).

Now, the cli defensively check for it. It also try to find the target wasm32-unknown-unknown in case is not installed.

Closes #1971.

API and ABI breaking changes

If this is an API or ABI breaking change, please apply the
corresponding GitHub label.

Expected complexity level and risk

1

Testing

Describe any testing you've done, and any testing you'd like your reviewers to do,
so that you're confident that all the changes work as expected!

  • Write a test
  • Run manually in windows

@mamcx mamcx added CLI only This change only affects the CLI behavior release-1.0 labels Nov 14, 2024
@mamcx mamcx requested a review from gefjon November 14, 2024 18:24
@mamcx mamcx self-assigned this Nov 14, 2024
use super::*;

#[test]
fn test_has_target() -> anyhow::Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cool if we could, like, configure a system here with both configurations and check, but that's not really feasible in a Rust test. I think this test is ok as-is, assuming we have wasm32 on CI.

Copy link
Contributor

@kazimuth kazimuth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

use std::path::Path;

/// Find an executable in the `PATH`.
pub(crate) fn find_executable(exe_name: impl AsRef<Path>) -> Option<std::path::PathBuf> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also https://github.com/harryfei/which-rs/, but it seems to mostly do stuff we don't need, so I think this is fine for now.

crates/cli/src/detect.rs Outdated Show resolved Hide resolved
crates/cli/src/detect.rs Outdated Show resolved Hide resolved
crates/cli/src/detect.rs Outdated Show resolved Hide resolved
crates/cli/src/detect.rs Outdated Show resolved Hide resolved
println!("Warning: Failed to install rustfmt: {err}");
}
} else {
return Err(anyhow::anyhow!("rustfmt is not installed. Please install it."));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a bit strange to me that if we fail to install rustfmt above, we just print a warning, but if we don't have rustup at all then we return an error. Should we print a warning in this case too, or should we return an Err above?

println!("Warning: Failed to install wasm32-unknown-unknown target: {}", err);
}
} else {
anyhow::bail!("wasm32-unknown-unknown target is not installed. Please install it.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comment here as above - strange that we bail if rustup is missing, but only warn if rustup fails to install the target.

@bfops
Copy link
Collaborator

bfops commented Nov 22, 2024

Looks basically good to me, two small comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI only This change only affects the CLI behavior release-1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI should not depend on rustup
4 participants