The vendored feature will try to compile libyara from sources present in the yara-sys/yara folder. When cloning the repo, by default this folder is empty, unless you cloned it with git clone --recursive, because git does not initialize submodules unless you ask it to.
This error only happens when manually cloning the yara-rust repo, and trying it out. When depending on it, cargo will always make sure to recursively clone it.
This PR adds a new check in yara-sys/build.rs to detect an empty yara-sys/yara folder, and ask the user to initialise its submodules when the vendored feature is used.
I tested it on a fresh clone of the repo, and the compilation fails as expected:
$ cargo run --example tutorial --features vendored
Compiling yara-sys v0.17.0 (/home/orycterope/workspace/yara-rust-clone/yara-sys)
error: failed to run custom build command for `yara-sys v0.17.0 (/home/orycterope/workspace/yara-rust-clone/yara-sys)`
Caused by:
process didn't exit successfully: `/home/orycterope/workspace/yara-rust-clone/target/debug/build/yara-sys-2e2f5460b9b0dd8f/build-script-build` (exit status: 101)
--- stderr
thread 'main' panicked at 'yara submodule folder /home/orycterope/workspace/yara-rust-clone/yara-sys/yara is empty, please initialize it with `git submodule init && git submodule update`', yara-sys/build.rs:8
7:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
followed ikrivosheev 's suggestions. Clippy still fails because of globwalk. This has nothing to do with this PR, and I feel like this should be resolved in another one.
The
vendored
feature will try to compile libyara from sources present in theyara-sys/yara
folder. When cloning the repo, by default this folder is empty, unless you cloned it withgit clone --recursive
, because git does not initialize submodules unless you ask it to.This results in obscure compilation errors about missing
libyara/proc/linux.c
, and can cause quite some confusion for new users that just want to try out the crate (see https://github.com/Hugal31/yara-rust/issues/106#issuecomment-1480920536).This error only happens when manually cloning the yara-rust repo, and trying it out. When depending on it, cargo will always make sure to recursively clone it.
This PR adds a new check in yara-sys/build.rs to detect an empty
yara-sys/yara
folder, and ask the user to initialise its submodules when the vendored feature is used.I tested it on a fresh clone of the repo, and the compilation fails as expected: