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: go work init . adds ./. instead of . #51448

Closed
bcmills opened this issue Mar 3, 2022 · 7 comments
Closed

cmd/go: go work init . adds ./. instead of . #51448

bcmills opened this issue Mar 3, 2022 · 7 comments
Labels
modules NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@bcmills
Copy link
Member

bcmills commented Mar 3, 2022

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

~/src/golang.org/x/exp$ gotip version
go version devel go1.19-6da16b6ad Tue Mar 1 23:49:01 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

It reproduces with go1.18rc1, yes.

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

go env Output
~/src/golang.org/x/exp$ gotip env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/bcmills/.cache/go-build"
GOENV="/usr/local/google/home/bcmills/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/tmp/tmp.dpCQFoAKTg/.gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/tmp/tmp.dpCQFoAKTg/.gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/google/home/bcmills/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/google/home/bcmills/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.19-6da16b6ad Tue Mar 1 23:49:01 2022 +0000"
GCCGO="/usr/local/google/home/bcmills/bin/gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/usr/local/google/home/bcmills/src/golang.org/x/exp/go.mod"
GOWORK="/usr/local/google/home/bcmills/src/golang.org/x/exp/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1424670007=/tmp/go-build -gno-record-gcc-switches"

What did you do?

~/src/golang.org/x/exp$ gotip work init .

~/src/golang.org/x/exp$ cat go.work

What did you expect to see?

go 1.19

use .

What did you see instead?

go 1.19

use ./.

CC @matloob

@bcmills bcmills added modules NeedsFix The path to resolution is known, but the work has not been done. labels Mar 3, 2022
@bcmills bcmills added this to the Go1.18 milestone Mar 3, 2022
@bcmills
Copy link
Member Author

bcmills commented Mar 3, 2022

The argument . should trigger modfile.IsDirectoryPath here:
https://cs.opensource.google/go/go/+/ce427cf96128b545ae473983bafb6a0b80ecaa08:src/cmd/go/internal/modload/modfile.go;l=805-807

But it doesn't: this looks like a bug in IsDirectoryPath, which does not expect to ever need to refer to a module in the same directory (compare #34417).

For Go 1.19, we should probably fix up modfile.IsDirectoryPath. For 1.18, perhaps we should change the condition to if path == "." || modfile.IsDirectoryPath(path).

@gopherbot
Copy link

Change https://go.dev/cl/389854 mentions this issue: cmd/go: make paths consistent between 'go work init' and 'go work use'

@gopherbot
Copy link

Change https://go.dev/cl/389298 mentions this issue: [release-branch.go1.18] cmd/go: make paths consistent between 'go work init' and 'go work use'

@bcmills bcmills reopened this Mar 3, 2022
@bcmills
Copy link
Member Author

bcmills commented Mar 3, 2022

Reopening for 1.18 backport.

@gopherbot
Copy link

Change https://go.dev/cl/389299 mentions this issue: [release-branch.go1.18] cmd/go: error out of 'go work use' if no directories are given

gopherbot pushed a commit that referenced this issue Mar 7, 2022
…k init' and 'go work use'

Fixes #51448

Change-Id: I86719b55037c377eb82154e169d8a9bbae20b77c
Reviewed-on: https://go-review.googlesource.com/c/go/+/389854
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
(cherry picked from commit 87a345c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/389298
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
gopherbot pushed a commit that referenced this issue Mar 7, 2022
…ctories are given

Otherwise, the behavior of 'go work use -r' (without arguments)
may be surprising.

For #51448.

Change-Id: I50cf1339591720ec5bd333146b89c9944ce420d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/389855
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 4f80943)
Reviewed-on: https://go-review.googlesource.com/c/go/+/389299
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
@dmitshur
Copy link
Contributor

dmitshur commented Mar 7, 2022

Closed by merging commits 839c0f3 (CL 389298) and 40f6480 (CL 389299) to release-branch.go1.18.

@gopherbot
Copy link

Change https://go.dev/cl/500355 mentions this issue: cmd: update vendored golang.org/x/mod

gopherbot pushed a commit that referenced this issue Oct 26, 2023
Pull in CL 500335. It teaches modfile.IsDirectoryPath to recognize all
relative paths that begin with a "." or ".." path element as a valid
directory path (rather than a module path). This allows removing the
path == "." check that CL 389298 added to modload.ToDirectoryPath.

go get golang.org/x/mod@6e58e47c  # CL 500335
go mod tidy
go mod vendor

Updates #51448.
Fixes #60572.

Change-Id: Ide99c728c8dac8fd238e13f6d6a0c3917d7aea2d
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/500355
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants