Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Check if rustc exists before building a Rust project type #1461

Merged
merged 2 commits into from
Jul 27, 2020

Conversation

ObsidianMinor
Copy link
Contributor

Fixes #487

@ObsidianMinor ObsidianMinor requested a review from a team as a code owner July 23, 2020 22:15
Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper left a comment

Choose a reason for hiding this comment

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

looks good! thanks for adding this 😄

src/build/mod.rs Outdated
@@ -13,6 +13,9 @@ pub fn build(target: &Target) -> Result<(), failure::Error> {
message::info("JavaScript project found. Skipping unnecessary build!")
}
TargetType::Rust => {
let _ = which::which("rustc")
.map_err(|e| failure::format_err!("'rustc' not found: {}", e))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

use wrangler::terminal::styles;
let rust_url = styles::url("https://www.rust-lang.org/tools/install");
Suggested change
.map_err(|e| failure::format_err!("'rustc' not found: {}", e))?;
.map_err(|e| failure::format_err!("'rustc' not found, installation documentation can be found here: {}, rust_url))?;

Copy link
Contributor

Choose a reason for hiding this comment

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

lets point the devs in the right direction for installation here just so it's easy for them to find.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be good to still print the error message. Maybe:

                .map_err(|e| failure::format_err!(
"'rustc' not found: {}. Installation documentation can be found here: {}",
e, styles::url("https://www.rust-lang.org/tools/install")))?;

Copy link
Contributor

Choose a reason for hiding this comment

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

what does the error message look like when it's printed out there? can you give an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it'd look something like:
'rustc' not found: cannot find binary path. Installation documentation can be found here: https://www.rust-lang.org/tools/install

Where "cannot find binary path" would be any of the messages from which::Error

#[derive(thiserror::Error, Copy, Clone, Eq, PartialEq, Debug)]
pub enum Error {
    #[error("bad absolute path")]
    BadAbsolutePath,
    #[error("bad relative path")]
    BadRelativePath,
    #[error("cannot find binary path")]
    CannotFindBinaryPath,
    #[error("cannot get current directory")]
    CannotGetCurrentDir,
    #[error("cannot canonicalize path")]
    CannotCanonicalize,
}

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 sounds good to me

Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper left a comment

Choose a reason for hiding this comment

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

thanks :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure that rustc and other dependencies are installed before building a rust project
2 participants