bazelbuild / rules_rust

Rust rules for Bazel
https://bazelbuild.github.io/rules_rust/
Apache License 2.0
667 stars 431 forks source link

Setup instructions for rust_analyzer fail to build #2321

Open bbstilson opened 11 months ago

bbstilson commented 11 months ago

WORKSPACE:

http_archive(
    name = "rules_rust",
    sha256 = "36ab8f9facae745c9c9c1b33d225623d976e78f2cc3f729b7973d8c20934ab95",
    urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.31.0/rules_rust-v0.31.0.tar.gz"],
)

load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")

rules_rust_dependencies()

rust_register_toolchains()

load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies")

# https://bazelbuild.github.io/rules_rust/rust_analyzer.html#setup
rust_analyzer_dependencies()
bazel run @rules_rust//tools/rust_analyzer:gen_rust_project

Output:

✗ bazel run @rules_rust//tools/rust_analyzer:gen_rust_project
INFO: Invocation ID: 45c19b76-e78b-43f2-8f45-0bbb2e0c8be3
ERROR: /home/bb/.cache/bazel/_bazel_bb/60385f905182673b726e25229e70b273/external/rules_rust/util/process_wrapper/BUILD.bazel:55:14: in _native_binary rule @rules_rust//util/process_wrapper:bootstrap_process_wrapper: 
Traceback (most recent call last):
    File "/home/bb/.cache/bazel/_bazel_bb/60385f905182673b726e25229e70b273/external/bazel_skylib/rules/native_binary.bzl", line 42, column 22, in _impl
        return _impl_rule(ctx, ctx.attr.is_windows)
    File "/home/bb/.cache/bazel/_bazel_bb/60385f905182673b726e25229e70b273/external/bazel_skylib/rules/native_binary.bzl", line 33, column 23, in _impl_rule
        files = depset(items = [out]),
Error in depset: depset() got unexpected keyword argument 'items'

Tested on version 0.33, 0.32, and 0.31

bbstilson commented 11 months ago

Actually, I can't seem to build anything.

.
├── BUILD.bazel
└── src
    └── main.rs
load("@rules_rust//rust:defs.bzl", "rust_binary")

package(default_visibility = ["//visibility:public"])

rust_binary(
    name = "foo",
    srcs = ["src/main.rs"],
)
bazel run //:foo

INFO: Invocation ID: 0b6345d8-3512-450b-8ffb-ac3504f3aefc
ERROR: /home/bb/.cache/bazel/_bazel_bb/60385f905182673b726e25229e70b273/external/rules_rust/util/process_wrapper/BUILD.bazel:55:14: in _native_binary rule @rules_rust//util/process_wrapper:bootstrap_process_wrapper: 
Traceback (most recent call last):
        File "/home/bb/.cache/bazel/_bazel_bb/60385f905182673b726e25229e70b273/external/bazel_skylib/rules/native_binary.bzl", line 42, column 22, in _impl
                return _impl_rule(ctx, ctx.attr.is_windows)
        File "/home/bb/.cache/bazel/_bazel_b/60385f905182673b726e25229e70b273/external/bazel_skylib/rules/native_binary.bzl", line 33, column 23, in _impl_rule
                files = depset(items = [out]),
Error in depset: depset() got unexpected keyword argument 'items'
ERROR: /home/bb/.cache/bazel/_bazel_bb/60385f905182673b726e25229e70b273/external/rules_rust/util/process_wrapper/BUILD.bazel:55:14: Analysis of target '@rules_rust//util/process_wrapper:bootstrap_process_wrapper' failed
ERROR: Analysis of target '//:foo' failed; build aborted: 
INFO: Elapsed time: 0.236s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 1 target configured)
FAILED: Build did NOT complete successfully (1 packages loaded, 1 target configured)
UebelAndre commented 11 months ago

I'm not sure how you're getting this. I don't see those lines of code in https://github.com/bazelbuild/bazel-skylib/blob/1.3.0/rules/native_binary.bzl. Somehow you're getting an older rev but I don't see in rules_rust where we'd be pinning back that far https://github.com/bazelbuild/bazel-skylib/blob/1.0.2/rules/native_binary.bzl#L33

Are you sure this is the entire WORKSPACE?

bbstilson commented 11 months ago

No, it's not the whole WORKSPACE, just the parts related to the rust rules. This is in a large mono-repo with ~800 LOC in the workspace file.

I'm sorry, I'm not super familiar with bazel. Is there something in the workspace file that I should be looking for that would cause this?