rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

Make complete bazel_env development setup possible

Open kolloch opened this issue 1 year ago • 2 comments

bazel_env aims to provision all needed dev tools from Bazel Toolchains.

There is already an example of how to use it with rules_rust in examples/bazel_env.

This setup is already usable but some "rust components" are missing. These pieces are special in so far they are "only" needed for development and not for a Bazel build:

  • rust-src: The sources for the standard library.
  • rust-analyzer: Maybe rust_analyzer (even though visual code seems to have downloaded it on its own, other IDEs might vary)

Example complaint from the "Visual Code Rust Analyzer" extension:

Workspace `/home/peter/nexxiot/nx0/Cargo.toml` has sysroot errors: can't load standard library from sysroot

/home/peter/.cache/bazel/_bazel_peter/c3168268db16f5d2c086cccc078019b4/external/rules_rust~~rust~rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools

(discovered via `rustc --print sysroot`)

try installing the Rust source the same way you installed rustc

One could special case these components or provide a general mechanism to specify which components to include.

There is already one "components-themed" arguement in rust_register_toolchains, maybe we could add an additional one like additional_components?

kolloch avatar Jul 02 '24 08:07 kolloch

@fmeum Do you have any opinion on this? This leads to e.g. rust-analyzer not being able to use the binaries provided by bazel_env due to it not finding rust-src.

purkhusid avatar Mar 27 '25 10:03 purkhusid

I don't really now much about rust, but adding a new attribute to the existing toolchain tags that allows specifying additional components sounds pretty good to me.

fmeum avatar Mar 28 '25 09:03 fmeum