rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

Rust Analyzer does not work in bzlmod

Open purkhusid opened this issue 1 year ago • 3 comments

There seems to be a couple of issues with the Rust Analyzer project generator.

  1. The workaround here: https://github.com/bazelbuild/rules_rust/blob/4136f6fedd033108294138a657b4ccd8ac57c8ef/tools/rust_analyzer/main.rs#L34 does not work with bzlmod and AFAIK is no longer needed for bzlmod. If I just set the name to rules_rust it works and gets further into generating the project.
  2. The generator uses the runfiles library and that library does not support bzlmod: https://github.com/bazelbuild/rules_rust/blob/4136f6fedd033108294138a657b4ccd8ac57c8ef/tools/rust_analyzer/lib.rs#L67

Updating the Runfiles library to support is a bit bigger task since but there is prior art in e.g. rules_go/python/java/dotnet

purkhusid avatar Jan 23 '24 15:01 purkhusid

The runfiles library needs to be updated to read _repo_mapping from the runfiles base directory to map repo names to the canonical name on disk. It's a simple file format (1 item per line, each line with 3 comma separated values, with no ambiguity as the values cannot contain commas).

More details are available here: https://github.com/bazelbuild/proposals/blob/main/designs/2022-07-21-locating-runfiles-with-bzlmod.md.

csmulhern avatar Jan 28 '24 00:01 csmulhern

After #2450, gen_rust_project works for me. Is there another issue here?

cameron-martin avatar Feb 02 '24 21:02 cameron-martin

After #2450, gen_rust_project works for me. Is there another issue here?

I believe #2440 is also necessary.

csmulhern avatar Feb 02 '24 22:02 csmulhern

@UebelAndre @illicitonion shall we close this issue? The runfiles library has been fixed to work with bzlmod

dzbarsky avatar Aug 15 '24 23:08 dzbarsky

@UebelAndre @illicitonion shall we close this issue? The runfiles library has been fixed to work with bzlmod

Seems resolved to me, thanks for the ping!

UebelAndre avatar Aug 16 '24 00:08 UebelAndre