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: vendoring behavior in workspace mode should be clarified #54130

Open
h31 opened this issue Jul 29, 2022 · 1 comment
Open

cmd/go: vendoring behavior in workspace mode should be clarified #54130

h31 opened this issue Jul 29, 2022 · 1 comment
Labels
Documentation NeedsInvestigation
Milestone

Comments

@h31
Copy link

@h31 h31 commented Jul 29, 2022

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

$ go version
go version go1.19rc2 darwin/amd64

Does this issue reproduce with the latest release?

Yes (also reproduces on 1.18.4)

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/artyom/Library/Caches/go-build"
GOENV="/Users/artyom/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/artyom/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/artyom/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/artyom/go/go1.19rc2"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/artyom/go/go1.19rc2/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19rc2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/artyom/GoTestProjects/Workspace/WorkspaceWithVendoring/go.mod"
GOWORK="/Users/artyom/GoTestProjects/Workspace/WorkspaceWithVendoring/go.work"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pr/5k6c2yx97cjb9t5fh0httxv80000gn/T/go-build3616914050=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Clone https://github.com/h31/WorkspaceWithVendoring
  • a simple project with go.work file and vendor directory containing a fake library
  • link to a file with faked code
  1. Run go build, and then ./my_workspace

What did you expect to see?

The documentation implies that workspace mode and vendoring are incompatible:

  • By default, if the go version in go.mod is 1.14 or higher and a vendor directory is present, the go command acts as if -mod=vendor were used. from Go Modules Reference
  • A manual run of go build -mod=vendor produces an error:
go: -mod may only be set to readonly when in workspace mode, but it is set to "vendor"
        Remove the -mod flag to use the default readonly value,
        or set GOWORK=off to disable workspace mode.

The original workspace proposal explicitly stated that vendoring is ignored in workspace mode:

Module vendoring is ignored in workspace mode because it is not clear which modules' vendor directories should be respected if there are multiple workpace modules with vendor directories containing the same dependencies.

What did you see instead?

$ go build
$ ./my_workspace
Fake library is used

Explicitly specifying -mod=readonly (which theoretically is the only option value compatible with workspace mode):

$ go build -mod=readonly
$ ./my_workspace
Testphrase
@cherrymui cherrymui added Documentation NeedsInvestigation labels Jul 29, 2022
@cherrymui cherrymui added this to the Backlog milestone Jul 29, 2022
@cherrymui
Copy link
Member

@cherrymui cherrymui commented Jul 29, 2022

cc @bcmills

@cherrymui cherrymui modified the milestones: Backlog, Go1.19 Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

2 participants