-
Notifications
You must be signed in to change notification settings - Fork 92
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
Bug with build.rs and built
crate
#6
Comments
This is a bit more difficult to track down since we do not have a stack trace with line numbers. Do you know what exactly failed? I don't see a plain "unwrap" in write_built_file_with_opts. The primary reason for build.rs to fail so far has been differing environment variables between If you have any time to debug this issue, it would be nice to track down the exact line that fails. |
There are a couple of unwraps in built::write_built_file, precisely dealing with obtaining environment variables, but it seems that both the env vars needed are exported according to the link you posted. I need to study some more Nix to work out how to enter the build environment to introspect any more, i think. |
Since it might come in handy in other situations, this is how I debugged this.
diff --git a/src/lib.rs b/src/lib.rs
index 52f7034..eae149c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -380,7 +380,7 @@ fn write_env<T: io::Write>(envmap: &EnvironmentMap, w: &mut T) -> io::Result<()>
macro_rules! write_env_str {
($(($name:ident, $env_name:expr,$doc:expr)),*) => {$(
writeln!(w, "#[doc={}]\npub const {}: &str = \"{}\";",
- stringify!($doc), stringify!($name), envmap.get($env_name).unwrap())?;
+ stringify!($doc), stringify!($name), envmap.get($env_name).expect(stringify!($env_name)))?;
)*}
}
diff --git a/Cargo.toml b/Cargo.toml
index 15ca171..54696bd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,7 @@ readme = "README.md"
build = "build.rs"
[build-dependencies]
-built = "0.3.0"
+built = { path = "../built" }
man = "0.3.0"
[dev-dependencies]
{ pkgs? import <nixos-unstable> { config = {}; }, callPackage? pkgs.callPackage }:
let cargo = callPackage ./Cargo.nix {};
in cargo.root_crate.overrideAttrs (attrs: {
CARGO_PKG_VERSION_PRE = "";
CARGO_PKG_HOMEPAGE = "";
}) With this, the crate builds (via |
(This means that we have to patch buildRustCrate to always provide this env variables) |
The fix is here: NixOS/nixpkgs#60127 |
Excellent stuff, thanks for the debugging info too! |
Can confirm that this now works for url-bot-rs, now that the Nixpkgs patch has been merged. |
Thanks for checking the fix! :) |
Error building https://github.com/nuxeh/url-bot-rs, this time with a
build.rs
...The text was updated successfully, but these errors were encountered: