rules_rust 0.57.1 cargo login is ineffective
I have a very simple project that works with 0.56 but not with 0.57.1 and I found the offending PR.
- 5e904830 (#3148) - does not work and fails with the error msg below.
- 1d0fe8a1 (#3067) - works.
Error msg:
failed to query replaced source registry `crates-io`
Caused by:
no token found for `artifactory`, please run `cargo login --registry artifactory`
or use environment variable CARGO_REGISTRIES_ARTIFACTORY_TOKEN
The MODULE.bazel:
bazel_dep(name = "rules_rust", version = "0.57.1")
bazel_dep(name = "platforms", version = "0.0.11")
git_override(
module_name = "rules_rust",
# commit = "5e904830", # [x] Updated crate_universe bzlmod to support skipping splicing (#3148) is breaking us.
commit = "1d0fe8a1", # [o] Replace symlinks in the output of cargo build scripts (#3067)
remote = "https://github.com/bazelbuild/rules_rust.git",
)
# dev dependencies
bazel_dep(name = "toolchains_musl", version = "0.1.20", dev_dependency = True)
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = "2021",
versions = ["1.81.0"],
extra_target_triples = ["x86_64-unknown-linux-musl"],
)
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
crate.from_cargo(
name = "crates",
cargo_lockfile = "//:Cargo.lock",
cargo_config = "//:.cargo/config.toml",
manifests = [
"//my_project:Cargo.toml"
],
)
use_repo(crate, "crates")
toolchains_musl = use_extension("@toolchains_musl//:toolchains_musl.bzl", "toolchains_musl", dev_dependency = True)
toolchains_musl.config()
I am running cargo login after the error message, but continue getting the same error.
Be nice to run something like this for testing in the future running a private crates io locally so we can ensure major changes do not break private crates repositories
Sorry for the breakage! Definitely having some testing would help. Ideally something that doesn't need as much infrastructure though. I'd be happy to review a PR from anyone with a repro case and help stand up some regression test!
Just a heads up that I personally don't plan to work on this as all my bazel time allowance is consumed by rules_python. But if anyone wants me to test a fix, I would be more than willing to.
I ended up digging thru the code and debugging and the culprit seems to be the isolated = true default argument. If i run
CARGO_BAZEL_ISOLATED=false bazel build //...
It seems to work. @aignas can you confirm this fixes your issue?
Yup, running with CARGO_BAZEL_ISOLATED=false fixes the problem I am seeing.