rules_rust
rules_rust copied to clipboard
There's no documented way to bootstrap Cargo.lock, Cargo.Bazel.lock
Following the documentation for crate_universe, you will get build errors similar to this one:
ERROR: Error computing the main repository mapping: no such package '@crate_index//': Not a regular file: /Users/adam/code/santa/Cargo.lock
And the same error for Cargo.Bazel.lock.
As far as I can tell:
- If you're using a Cargo.toml, you bootstrap Cargo.lock using
cargo. If you're not using Cargo.toml you there is no clear way to bootstrap it. - If you're specifying Cargo.Bazel.lock, then the docs don't tell you how to bootstrap it.
CARGO_BAZEL_REPIN=1 bazel ...will not do it. By experimenting, I've figured out that if youtouch Cargo.Bazel.lockbefore running bazel, it'll work.
I would suggest the documentation page should mention:
- How to bootstrap
cargo_lockfilewithout a Cargo.toml (I don't know, actually) - That
lockfilewill be bootstrapped withtouch LOCKFILE && CARGO_BAZEL_REPIN=1 bazel test // - Add comments to the first example ("Cargo Workspaces") next to the lines specifying the lockfiles, telling the reader to bootstrap those files.
I’d be happy to review a PR to improve documentation 😄
actually this is mentioned in the crates_repository docs already, but it's not so obvious, i've also struggled to understand how to do this.