Skip to content

Commit 117ebe0

Browse files
author
Bryan C. Mills
committed
cmd/go: do not require the module cache to exist for 'go mod edit'
Updates #46695 Change-Id: I4afbc1401ef4183d94c1ac6271394fac1fff95ae Reviewed-on: https://go-review.googlesource.com/c/go/+/328769 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent 460900a commit 117ebe0

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/cmd/go/internal/modfetch/cache.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func lockVersion(mod module.Version) (unlock func(), err error) {
152152
// If err is nil, the caller MUST eventually call the unlock function.
153153
func SideLock() (unlock func(), err error) {
154154
if err := checkCacheDir(); err != nil {
155-
base.Fatalf("go: %v", err)
155+
return nil, err
156156
}
157157

158158
path := filepath.Join(cfg.GOMODCACHE, "cache", "lock")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 'go mod edit' opportunistically locks the side-lock file in the module cache,
2+
# for compatibility with older versions of the 'go' command.
3+
# It does not otherwise depend on the module cache, so it should not
4+
# fail if the module cache directory cannot be created.
5+
6+
[root] skip
7+
8+
mkdir $WORK/readonly
9+
chmod 0555 $WORK/readonly
10+
env GOPATH=$WORK/readonly/nonexist
11+
12+
go mod edit -go=1.17
13+
14+
-- go.mod --
15+
module example.com/m

0 commit comments

Comments
 (0)