-
Notifications
You must be signed in to change notification settings - Fork 380
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
Gazelle does not support unix
build tag (//go:build unix
)
#1465
Comments
btwiuse
pushed a commit
to btwiuse/k0s
that referenced
this issue
Mar 1, 2023
Note: make bazel-build is broken for now because of bazel-contrib/bazel-gazelle#1465
I'm also having this problem. For now I can only use |
btwiuse
pushed a commit
to btwiuse/k0s
that referenced
this issue
Mar 1, 2023
Note: make bazel-build is broken for now because of bazel-contrib/bazel-gazelle#1465
For people having this problem on dependencies included via |
connyay
added a commit
to connyay/bazel-gazelle
that referenced
this issue
Apr 19, 2023
connyay
added a commit
to connyay/bazel-gazelle
that referenced
this issue
Apr 19, 2023
fmeum
pushed a commit
to connyay/bazel-gazelle
that referenced
this issue
May 1, 2023
fmeum
pushed a commit
that referenced
this issue
May 1, 2023
* language/go: Handle `unix` build tag. Fixes #1465 * take out unix as a known os
connyay
added a commit
to connyay/bazel-gazelle
that referenced
this issue
May 30, 2023
Allows not skipping build files with unix tag and allowing the compiler to do the correct thing. Actually fixes bazel-contrib#1465
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of gazelle are you using?
v0.29.0
What version of rules_go are you using?
v0.38.1
What version of Bazel are you using?
v6.0.0
Does this issue reproduce with the latest releases of all the above?
Yes.
What operating system and processor architecture are you using?
Debian 11 amd64
What did you do?
I initially tried to depend on github.com/jackc/pgx/stdlib in a bazel project that uses gazelle.
However, that's annoying to reproduce minimally and cleanly, so the error can be minimally reproduced as follows:
On a unix machine, use
git apply
to apply this patch to an empty workspace (empty directory on whichgit init
has been run):Then, in that directory, run
bazel run //:gazelle
followed bybazel build //foo:foo
.What did you expect to see?
I expected to see, in the
foo/BUILD.bazel
file:with the relevant part being the
yes.go
file (which has the//go:build unix
line) included in thesrcs
list, as, per https://pkg.go.dev/cmd/go@go1.20.1#hdr-Build_constraints, theunix
build constraint should be satisfied "if GOOS is a Unix or Unix-like system", where the list of those systems can be found here:https://cs.opensource.google/go/go/+/refs/tags/go1.20.1:src/go/build/syslist.go;l=34-51 (Lines reproduced below for viewing convenience)
When I run
go env
on my machine, I getGOOS="linux"
, so I should satisfy that build constraint.I also expect that the build will then complete successfully.
What did you see instead?
Instead, my
foo/BUILD.bazel
file is the following:with the relevant part being the
no.go
file (which has the//go:build !unix
line) included in thesrcs
list instead of theyes.go
file. Further, the build fails with the following error:because when
go
actually builds those files, the!unix
build directive is not satisfied, so theno.go
file is not built, and theFoo
type is never defined. Note that if I change the"no.go",
line to"yes.go",
, the build succeeds.Edit: After testing with the tag
linux
instead ofunix
, I see that both files are included insrcs
. That would also be an acceptable outcome; I do not needno.go
excluded, I just needyes.go
included.The text was updated successfully, but these errors were encountered: