rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

There's no documented way to bootstrap Cargo.lock, Cargo.Bazel.lock

Open the80srobot opened this issue 2 years ago • 2 comments

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:

  1. 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.
  2. 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 you touch Cargo.Bazel.lock before running bazel, it'll work.

I would suggest the documentation page should mention:

  • How to bootstrap cargo_lockfile without a Cargo.toml (I don't know, actually)
  • That lockfile will be bootstrapped with touch 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.

the80srobot avatar Nov 23 '23 09:11 the80srobot

I’d be happy to review a PR to improve documentation 😄

UebelAndre avatar Nov 25 '23 21:11 UebelAndre

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.

PI-Victor avatar Nov 26 '23 11:11 PI-Victor