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

cmd/go: document that go mod vendor ignores directories that do not contain Go files #57529

Open
urandom2 opened this issue Dec 30, 2022 · 6 comments
Labels
Documentation GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@urandom2
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go1.19.4

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/colin/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/nix/store/a7875alzpnr46z6mv4ssymfdwmvr6xbq-go-1.19.4/share/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/nix/store/a7875alzpnr46z6mv4ssymfdwmvr6xbq-go-1.19.4/share/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3977569072=/tmp/go-build -gno-record-gcc-switches"

What did you do?

[user@localhost:~]$ git clone https://github.com/ava-labs/avalanchego
[user@localhost:~]$ cd avalanchego
[user@localhost:avalanchego]$ go build -o /dev/null ./main
[user@localhost:avalanchego]$ go mod vendor

What did you expect to see?

[user@localhost:avalanchego]$ go build -o /dev/null ./main

What did you see instead?

[user@localhost:avalanchego]$ go build -o /dev/null ./main
# github.com/supranational/blst/bindings/go
vendor/github.com/supranational/blst/bindings/go/blst.go:16:11: fatal error: blst.h: No such file or directory
   16 | // #include "blst.h"
      |           ^~~~~~~~
compilation terminated.
# github.com/zondax/hid
vendor/github.com/zondax/hid/hid_enabled.go:23:18: fatal error: os/threads_posix.c: No such file or directory
   23 |         #include "os/threads_posix.c"
      |                  ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
@seankhliao
Copy link
Member

working as intended.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Dec 30, 2022
@seankhliao
Copy link
Member

Duplicate of #26366

@seankhliao seankhliao marked this as a duplicate of #26366 Dec 30, 2022
@urandom2
Copy link
Contributor Author

urandom2 commented Dec 30, 2022

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

I am really confused, I am not "asking question" or trying to spark a "general discussion". I encountered an actual bug and was reporting it, as confirmed by your duplicate link. can you clarify what you mean?


also, I do think there is an outstanding bug, since the toolchain behaves differently with and without a vendor directory. sorry if I should have been more clear, but note that the project builds correctly before the call to go mod vendor:

[user@localhost:~]$ git clone https://github.com/ava-labs/avalanchego
[user@localhost:~]$ cd avalanchego
[user@localhost:avalanchego]$ go build -o /dev/null ./main
[user@localhost:avalanchego]$ 

@ianlancetaylor
Copy link
Contributor

Sorry for the confusing responses. This is the current expected behavior. See #26366 (comment) .

@urandom2
Copy link
Contributor Author

all good; I used a full repo as a reproducer, for simplicity, so I get it may have seemed like I was asking about "how do I build this thing".

that said, it really confuses me that we have intentionally chosen to have the module cache behave differently to the vendor directory. considering how big a foot gun this is, and how many other github issues link #26366, can we call this out in some documentation that is searchable? I tried googling around for an issue/faq entry, but ended up making a bug since I could not find one.

@ianlancetaylor
Copy link
Contributor

This should probably be clearly documented at least at https://go.dev/ref/mod#go-mod-vendor. CC @bcmills @matloob

@ianlancetaylor ianlancetaylor changed the title cmd/go: go mod vendor is missing files cmd/go: document that go mod vendor ignores directories that do not contain Go files Dec 30, 2022
@ianlancetaylor ianlancetaylor added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Dec 30, 2022
@ianlancetaylor ianlancetaylor added this to the Backlog milestone Dec 30, 2022
@seankhliao seankhliao added the GoCommand cmd/go label Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants