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

fix: Improve protoc not found error message #937

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions prost-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1516,24 +1516,21 @@ pub fn protoc_from_env() -> PathBuf {
}

pub fn error_message_protoc_not_found() -> String {
let error_msg = "Could not find `protoc`. If `protoc` is installed, try setting the `PROTOC` environment variable to the path of the `protoc` binary.";

let os_specific_hint = if cfg!(target_os = "macos") {
"You could try running `brew install protobuf` or downloading it from https://github.com/protocolbuffers/protobuf/releases"
"To install it on macOS, run `brew install protobuf`."
} else if cfg!(target_os = "linux") {
"If you're on debian, try `apt-get install protobuf-compiler` or download it from https://github.com/protocolbuffers/protobuf/releases"
"To install it on Debian, run `apt-get install protobuf-compiler`."
} else {
"You can download it from https://github.com/protocolbuffers/protobuf/releases or from your package manager."
"Try installing `protobuf-compiler` or `protobuf` using your package manager."
};
let error_msg =
"Could not find `protoc` installation and this build crate cannot proceed without
this knowledge. If `protoc` is installed and this crate had trouble finding
it, you can set the `PROTOC` environment variable with the specific path to your
installed `protoc` binary.";
format!(
"{}{}
let download_msg =
"It is also available at https://github.com/protocolbuffers/protobuf/releases";

For more information: https://docs.rs/prost-build/#sourcing-protoc
",
error_msg, os_specific_hint
format!(
"{} {} {} For more information: https://docs.rs/prost-build/#sourcing-protoc",
error_msg, os_specific_hint, download_msg
)
}

Expand Down
Loading