I've updated a library called 'ring' to include support for a custom target/OS. I've made the update directly in ~/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20. In the root Cargo.toml, there is a conditional dependency where I've added the custom OS to include the once_cell crate:
When I go to build, the conditional updated dependency isn't getting picked up:
RUST_BACKTRACE=1 cargo --offline build -Z build-std=core,alloc,compiler_builtins,panic_abort,std --target CUSTOM-TARGET --verbose
>> error[E0433]: failed to resolve: use of undeclared crate or module `once_cell`
I'm new to rust and trying to understand where this dependency is resolved and why it isn't getting picked up when I modify Cargo.toml. I was looking around for a cache and I noticed: ~/.cargo/registry/index/github.com-1ecc6299db9ec823/.cache/ri/ng/rin. There is no reference at all to the new CUSTOM-OS in there. I've tried nuking this cache entry and rebuilding to no avail. I've also tried adding the dependency as a non-conditional in Cargo.tom but it still doesn't get picked up. I'm clearly missing a fundamental understanding of how dependencies are resolved. Any help is greatly appreciated.
No issues with the OS being set. I've modified a bunch of crates and the error you see above only gets hit when the OS is properly defined. I had the same thought so tried adding once_cell as a static dependency (i.e. [dependencies.once_cell] without the cfg....). Same issue.
Update: Using a separate location for the crate did indeed solve the dependency issue; thank you very much for your answer. Still curious if there's a way to have a staging area for modified packages so i don't need to add this directive to every project?
Seeing how I'm adding an OS, there are quite a few crates I've mucked with. Is there a way I can tell cargo to always look in a staging area first via an ENV variable (i.e. search /local/crates before searching ~/.cargo/) or do I need to add this to every project I work on and keep a list of every crate I've modified? I'll go try this out and see if it handles the dependencies differently.