Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to generate initial Cargo.Bazel.lock #2632

Open
spemmons opened this issue Apr 28, 2024 · 1 comment
Open

Unable to generate initial Cargo.Bazel.lock #2632

spemmons opened this issue Apr 28, 2024 · 1 comment

Comments

@spemmons
Copy link

spemmons commented Apr 28, 2024

i have a working cargo workspace and am trying to add it to an existing bazel WORKSPACE file with the following standard definitions per the docs

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

rules_rust_dependencies()

rust_register_toolchains(
    edition = "2021",
)

load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")

crate_universe_dependencies()

load("@rules_rust//crate_universe:defs.bzl", "crates_repository")

crates_repository(
    name = "crate_index",
    cargo_lockfile = "//:Cargo.lock",
    lockfile = "//:Cargo.Bazel.lock",
    manifests = ["//system/bash-test:Cargo.toml"],
)

load("@crate_index//:defs.bzl", "crate_repositories")

crate_repositories()

cargo build works fine and generates the root-level Cargo.lock file

the Cargo.toml looks like this

[workspace]
resolver = "2"
members = [
...
]

i have an empty Cargo.Bazel.lock file via touch and call CARGO_BAZEL_REPIN=true bazel build and get the following error

Loading: 
ERROR: An error occurred during the fetch of repository 'crate_index':
   Traceback (most recent call last):
        File "/home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rules_rust/crate_universe/private/crates_repository.bzl", line 59, column 50, in _crates_repository_impl
                metadata_path = splice_workspace_manifest(
        File "/home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rules_rust/crate_universe/private/splicing_utils.bzl", line 175, column 12, in splice_workspace_manifest
                execute(
        File "/home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rules_rust/crate_universe/private/common_utils.bzl", line 54, column 13, in execute
                fail(_EXECUTE_ERROR_MESSAGE.format(
Error in fail: Command [/home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/cargo-bazel, "splice", "--output-dir", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/splicing-output, "--splicing-manifest", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/splicing_manifest.json, "--config", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/cargo-bazel.json, "--cargo", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/cargo, "--rustc", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/rustc, "--cargo-lockfile", /home/ubuntu/repositories/pennybot/Cargo.lock] failed with exit code 1.
STDOUT ------------------------------------------------------------------------

STDERR ------------------------------------------------------------------------
Error: Failed to query cargo version

Loading: 
ERROR: /home/ubuntu/repositories/pennybot/WORKSPACE:627:18: fetching crates_repository rule //external:crate_index: Traceback (most recent call last):
        File "/home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rules_rust/crate_universe/private/crates_repository.bzl", line 59, column 50, in _crates_repository_impl
                metadata_path = splice_workspace_manifest(
        File "/home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rules_rust/crate_universe/private/splicing_utils.bzl", line 175, column 12, in splice_workspace_manifest
                execute(
        File "/home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rules_rust/crate_universe/private/common_utils.bzl", line 54, column 13, in execute
                fail(_EXECUTE_ERROR_MESSAGE.format(
Error in fail: Command [/home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/cargo-bazel, "splice", "--output-dir", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/splicing-output, "--splicing-manifest", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/splicing_manifest.json, "--config", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/cargo-bazel.json, "--cargo", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/cargo, "--rustc", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/rustc, "--cargo-lockfile", /home/ubuntu/repositories/pennybot/Cargo.lock] failed with exit code 1.
STDOUT ------------------------------------------------------------------------

STDERR ------------------------------------------------------------------------
Error: Failed to query cargo version

Loading: 
ERROR: Error computing the main repository mapping: no such package '@crate_index//': Command [/home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/cargo-bazel, "splice", "--output-dir", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/splicing-output, "--splicing-manifest", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/splicing_manifest.json, "--config", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/crate_index/cargo-bazel.json, "--cargo", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/cargo, "--rustc", /home/ubuntu/.cache/bazel/_docker_bazel_ubuntu/cbf41e95e355e36f4faad74de7a872da/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/rustc, "--cargo-lockfile", /home/ubuntu/repositories/pennybot/Cargo.lock] failed with exit code 1.
STDOUT ------------------------------------------------------------------------

STDERR ------------------------------------------------------------------------
Error: Failed to query cargo version

Loading: 

i've searched the docs and google for hints about "cargo version" in this context and can't seem to find anything that helps

ideas? thanks

@UebelAndre
Copy link
Collaborator

Unfortunately there's not enough data here to answer your question, but I've added logging here in #2629 which should help explain what's going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants