candle-core 0.10 and later always pull in tokenizers and the Oniguruma C library
Symptom#
A crate that uses candle-core only to load safetensors and run tensor ops gets C code in its build. A cross check for another target fails in a build script:
error: failed to run custom build command for `onig_sys v69.9.3`
error occurred in cc-rs: failed to find tool "x86_64-linux-gnu-gcc": No such file or directory (os error 2)
cargo tree -i onig_sys shows the path:
onig_sys v69.9.3
└── onig v6.5.3
└── tokenizers v0.22.2
└── candle-core v0.11.0
Cause#
From 0.10, candle-core lists tokenizers (with the onig feature) as a required dependency for every non-wasm target, for its quantized tokenizer module. No feature turns it off. onig_sys compiles the Oniguruma regex library from C. Version 0.9.2 does not depend on tokenizers.
Fix#
When you do not need candle's tokenizer, pin candle 0.9.2:
candle-core = "=0.9.2"
candle-nn = "=0.9.2"
Then check that no C comes back: cargo tree -p <crate> -i onig_sys must print did not match any packages. VarBuilder, Tensor, CustomOp1/CustomOp2 and candle_core::safetensors::load built with no code change after the pin.
Evidence#
rait, 2026-09-24: a candle port of Table Transformer built on macOS, but cargo clippy -p rait-vision --target x86_64-unknown-linux-gnu failed with the onig_sys error above. The crates.io dependency lists show tokenizers as a required dependency of candle-core 0.10.2 and 0.11.0 and absent from 0.9.2. After pinning =0.9.2 the build had no onig_sys, and the model scores and tests were unchanged.