bazelbuild / bazelbuild/rules_rust

How to use the local rustc first instead of the default download

Open
#2,098 0 comments 0 reactions 0 assignees View on GitHub
needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

In my project, I introduce rules_rust:
```bash
http_archive(
name = "rules_rust",
sha256 = "4a9cb4fda6ccd5b5ec393b2e944822a62e050c7c06f1ea41607f14c4fdec57a2",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.25.1/rules_rust-v0.25.1.tar.gz"],
)
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")

rules_rust_dependencies()

rust_register_toolchains(
# https://doc.rust-lang.org/edition-guide/editions/
edition = "2021",
)
```
But when I bazel buid, I find that rustc will be downloaded first.
```bash
Loading:
Fetching repository @cargo_crate; Restarting.
Fetching https://static.rust-lang.org/dist/rustc-1.70.0-x86_64-unknown-linux-gnu.tar.gz; 657.2 KiB (672,974B)
root@xx:$ rustc --version
rustc 1.66.1 (90743e729 2023-01-10) (built from a source tarball)
```
Because rust_register_toolchains contains the urls parameter:
![image](https://github.com/bazelbuild/rules_rust/assets/139601623/5bd7ebcd-2bce-4c06-8e31-93e7344e4683)

I tried adding the local version to versions, but it still downloads:
```bash
diff --git a/WORKSPACE b/WORKSPACE
index e067840..3ae159f 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -14,6 +14,9 @@ rules_rust_dependencies()
rust_register_toolchains(
# https://doc.rust-lang.org/edition-guide/editions/
edition = "2021",
+ versions = [
+ "1.66.1",
+ ],
)

load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
```
```bash
Loading:
Fetching repository @cargo_crate; Restarting.
Fetching https://static.rust-lang.org/dist/rustc-1.66.1-x86_64-unknown-linux-gnu.tar.gz; 6.0 MiB (6,299,648B)
root@xx:$ rustc --version
rustc 1.66.1 (90743e729 2023-01-10) (built from a source tarball)
```
Is there any way to prohibit the download and use the local rustc directly?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.