-
Notifications
You must be signed in to change notification settings - Fork 435
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
clippy aspect causes go binaries to fail #1517
Comments
Can you provide a workspace as an example? I’m curious why it seems someone is trying to run clippy without registering any toolchains. Perhaps there’s more going on. |
Sure, this is a pretty minimal repro: # WORKSPACE
workspace(
name = "repro",
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
rules_go_version = "0.29.0"
http_archive(
name = "io_bazel_rules_go",
sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
url = "https://github.com/bazelbuild/rules_go/releases/download/v{}/rules_go-v{}.zip"
.format(rules_go_version, rules_go_version),
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(go_version = "1.18")
rules_rust_version = "0.9.0"
http_archive(
name = "rules_rust",
sha256 = "6bfe75125e74155955d8a9854a8811365e6c0f3d33ed700bc17f39e32522c822",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_rust/releases/download/{}/rules_rust-v{}.tar.gz".format(
rules_rust_version,
rules_rust_version,
),
"https://github.com/bazelbuild/rules_rust/releases/download/{}/rules_rust-v{}.tar.gz".format(
rules_rust_version,
rules_rust_version,
),
],
)
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
rules_rust_dependencies()
rust_register_toolchains(
edition = "2021",
) # BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@rules_rust//rust:defs.bzl", "rust_binary")
go_library(
name = "lib",
srcs = ["main.go"],
importpath = "main",
)
go_binary(
name = "bin",
out = "main",
embed = ["lib"],
goarch = "amd64",
goos = "linux",
pure = "on",
)
rust_binary(
name = "rust",
srcs = ["main.rs"],
) // main.go
package main
import "fmt"
func main() {
fmt.Println("hello world")
} // main.rs
fn main() {
println!("hello world");
} .bazelrcbuild --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
|
Seems you’re missing |
Sorry, I cut things too short. I've updated the repro with a rust binary too. I've also pushed it here: https://github.com/duarten/clippy-repro.
Something I forgot to mention: the issue happens because I'm cross-compiling the go binary (I'm running on mac, but if you'll notice, the go binary is targeting linux). There's no rust toolchain for that triplet. |
It seems The issue very likely comes form the
This error makes sense to me though since I'm building on my mac and have not registered any compatible toolchains. I'm not sure how relevant the message here is:
since I definitely haven't registered a toolchain and wouldn't expect one to be found on my host. Could you try maybe updating the version of |
rules_go changed how it does transitions fairly recently to be much more constrained in what it transitions - bazel-contrib/rules_go#3116 should have fixed this :) it was released in 0.34.0 |
Of course the issue was with Go :) Updating rules_go fixed it. Thanks for the help guys! |
When building with the clippy aspect, if there are go targets in the workspaces, then the build fails with
The go binary is a simple
go_binary
:The text was updated successfully, but these errors were encountered: