-
Notifications
You must be signed in to change notification settings - Fork 79
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
Improve error message when a library is not found #158
Conversation
Mostly just small tweaks to existing output, including the following new output: - Potential packages to install - Items in PKG_CONFIG_PATH - Command invocation
Missed some features introduced in 1.57; specifically |
…bles Before, this was accomplished by using `get_env` and `get_args` manually, but these features are unavailable in 1.30 (current MSRV). To get around this, `Command` is wrapped as `WrappedCommand` and tracks any environment variables or arguments that are set by the caller. Then, the `Display` implementation actually handles pretty-printing the invocation, with the added benefit that other errors can take advantage of this nicer output!
src/lib.rs
Outdated
let hint = if let Some(search_path) = search_path { | ||
writeln!( | ||
f, | ||
"PKG_CONFIG_PATH contains the following:\n{}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this confusing for NixOS users? Maybe remember from which variable the search path comes and print that here.
Looks good to me otherwise, thanks a lot :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch! Will write a quick fix.
As pointed out by @sdroege in rust-lang#158, Nix users would be misled when `PKG_CONFIG_PATH_FOR_TARGET` is listed in error output but mistakenly named `PKG_CONFIG_PATH`.
Apologies for the commit spam, I'm very out of practice using Git! Please let me know if there is anything else I can do. |
Thanks :) |
I've noticed that people trying to build a crate which links against a missing library can sometimes be confused by this library's error output. This PR introduces a re-worked error message for that case that focuses on communicating:
Before (trimmed
build.rs
output for libsodium-sys-stable):After:
Thanks to everyone for their invaluable feedback on zulip: https://rust-lang.zulipchat.com/#narrow/stream/351149-t-libs.2Fcrates/topic/More.20helpful.20pkg-config.20output
If there's anything that should be changed please let me know :)