You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to set up Bazel to build a Rust project. I followed the instructions in the documentation, and I can successfully build an executable. However, I have trouble in using the Rust analyzer extension. Specifically, I get
~/MWE$ bazel build //rust:executable-rs
Starting local Bazel server and connecting to it...
WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to https://github.com/bazelbuild/bazel/issues/18958.
ERROR: Traceback (most recent call last):
File "/home/abertulli/MWE/rust/BUILD.bazel", line 9, column 27, in <toplevel>
rust_analyzer_dependencies()
File "/home/abertulli/.cache/bazel/_bazel_abertulli/b2e37475533f474e11fd385fceaab463/external/rules_rust/tools/rust_analyzer/deps.bzl", line 9, column 30, in rust_analyzer_dependencies
return crate_repositories()
File "/home/abertulli/.cache/bazel/_bazel_abertulli/b2e37475533f474e11fd385fceaab463/external/rules_rust/tools/rust_analyzer/3rdparty/crates/defs.bzl", line 413, column 10, in crate_repositories
maybe(
File "/home/abertulli/.cache/bazel/_bazel_abertulli/b2e37475533f474e11fd385fceaab463/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 268, column 18, in maybe
repo_rule(name = name, **kwargs)
Error in repository_rule: 'repository rule http_archive' can only be called during workspace loading
WARNING: Target pattern parsing failed.
ERROR: Skipping '//rust:executable-rs': Error evaluating '//rust:executable-rs': error loading package 'rust': Package 'rust' contains errors
ERROR: Error evaluating '//rust:executable-rs': error loading package 'rust': Package 'rust' contains errors
INFO: Elapsed time: 7.895s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
If I comment the two lines using the Rust analyzer extension I can compile successfully. Also notice how it created an (empty) MODULE.bazel and a MODULE.bazel.lock file. However, I also tried the new approach using MODULE.bazel (see below), but I got the same error. I don't know if I misread the docs, or if they are not mentioning something. What am I doing worng? Thanks!
Hi, first of all, thank you for your work.
I am trying to set up Bazel to build a Rust project. I followed the instructions in the documentation, and I can successfully build an executable. However, I have trouble in using the Rust analyzer extension. Specifically, I get
If I comment the two lines using the Rust analyzer extension I can compile successfully. Also notice how it created an (empty)
MODULE.bazel
and aMODULE.bazel.lock
file. However, I also tried the new approach usingMODULE.bazel
(see below), but I got the same error. I don't know if I misread the docs, or if they are not mentioning something. What am I doing worng? Thanks!MWE
WORKSPACE.bazel
:rust/BUILD.bazel
:rust/main.rs
:MODULE.bazel
that I tried:that gave me the same
The text was updated successfully, but these errors were encountered: