build-rust-crate: ensure info about build.rs failures reaches the log#190592
Conversation
When execution of a `build.rs` script fails, information about the failure is sent to stdout (using "cargo:foo=" prefixes) rather than stderr. Because of this, information needed to diagnose the failure is not available in `nix log`. An example of that information is found below. Let's do the simplest thing possible, and replace `>` with `tee` so the output of executing `build.rs` gets copied to the log. cargo:warning=Could not run `"pkg-config" "--libs" "--cflags" "cairo" "cairo >= 1.14"` The pkg-config command could not be found. Most likely, you need to install a pkg-config package for your OS. Try `apt install pkg-config`, or `yum install pkg-config`, or `pkg install pkg-config` depending on your distribution. If you've already installed it, ensure the pkg-config command is one of the directories in the PATH environment variable. If you did not expect this build to link to a pre-installed system library, then check documentation of the cairo-sys-rs crate for an option to build the library from source, or disable features or dependencies that require pkg-config.
bjornfor
reviewed
Sep 11, 2022
| # build script failures are reported to stdout rather than stderr, so we | ||
| # use tee here instead of > to ensure that `nix log` contains useful | ||
| # information when a failure occurs | ||
| target/build/${crateName}/build_script_build | tee target/build/${crateName}.opt |
Contributor
There was a problem hiding this comment.
Is this script snippet run with "set -o pipefail"? If it isn't, then the pipe will suppress failures.
Author
There was a problem hiding this comment.
Thank you for noticing that. How embarrassing. What I wrote would have silently omitted features when the build script fails.
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
When execution of a
build.rsscript fails, information about the failure is sent to stdout (using "cargo:foo=" prefixes) rather than stderr. Because of this, information needed to diagnose the failure is not available innix log. An example of that information is found below.Let's do the simplest thing possible, and replace
>withteeso the output of executingbuild.rsgets copied to the log.Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes