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

Cannot build Rust library using derive_builder #594

Closed
agentydragon opened this issue Feb 20, 2021 · 2 comments
Closed

Cannot build Rust library using derive_builder #594

agentydragon opened this issue Feb 20, 2021 · 2 comments

Comments

@agentydragon
Copy link

This is an example repository with a simple Rust binary using derive_builder crate: https://gitlab.com/agentydragon/test
The repository has rules_rust pointed at commit 9aa4956.

This is my Bazel output trying to compile the binary:

error: couldn't read external/raze__derive_builder__0_9_0/src/doc_tpl/builder_struct.md: No such file or directory (os error 2)
   --> external/raze__derive_builder__0_9_0/src/lib.rs:615:9
    |
615 |         include_str!("doc_tpl/builder_struct.md"),
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: couldn't read external/raze__derive_builder__0_9_0/src/doc_tpl/builder_method.md: No such file or directory (os error 2)
   --> external/raze__derive_builder__0_9_0/src/lib.rs:619:9
    |
619 |         include_str!("doc_tpl/builder_method.md"),
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors

ERROR: /home/agentydragon/.cache/bazel/_bazel_agentydragon/867bf77deb07710cf7b0ca4ecebee8dd/external/raze__derive_builder__0_9_0/BUILD.bazel:73:13: output 'external/raze__derive_builder__0_9_0/libderive_builder--244701270.so' was not created
ERROR: /home/agentydragon/.cache/bazel/_bazel_agentydragon/867bf77deb07710cf7b0ca4ecebee8dd/external/raze__derive_builder__0_9_0/BUILD.bazel:73:13: Compiling Rust proc-macro derive_builder v0.9.0 (43 files) failed: not all outputs were created or valid
Target //:test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 81.999s, Critical Path: 32.98s
INFO: 23 processes: 1 internal, 22 linux-sandbox.
FAILED: Build did NOT complete successfully
@agentydragon
Copy link
Author

agentydragon commented Feb 20, 2021

I don't feel like digging deep into how rules_rust works right now, but I'd expect this to be some issue with the Markdown templates not being in srcs of some generated rust_library, or generally not being visible within the build environment of the crate library.

I encountered this problem in the context of trying do write a Rust tool with the headless_chrome crate.

@agentydragon
Copy link
Author

agentydragon commented Feb 20, 2021

Solved by adding this to Cargo.toml:

[package.metadata.raze.crates.derive_builder.'*']
compile_data_attr = "glob([\"**/*.md\"])"

This is a case of google/cargo-raze#41.

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

No branches or pull requests

1 participant