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 install: don’t fail when go.mod can’t be updated on a read-only system #33326

Closed
stapelberg opened this issue Jul 28, 2019 · 6 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@stapelberg
Copy link
Contributor

$ go version
go version go1.13beta1 linux/amd64

I talked about this issue with @bcmills over GopherCon 2019 and he recommended I file this issue for tracking.

I am using cmd/go in a build environment where the entire system is read-only, but I have a writable copy of the source tree I’m building (e.g. github.com/junegunn/fzf). The system provides a read-only module cache (at /ro/gopath/pkg/mod) which contains all the dependencies of the source tree.

I’m using replace directives to enforce that my environment’s module versions are used, which can be different from the versions listed in go.mod/go.sum. See #29410 (comment) for details.

When running go install, it fails to lock the module cache because it’s read-only:

go: failed to lock file at /ro/gopath/pkg/mod/cache/lock

So far so good—it’s reasonable to not continuing when the side lock can’t be acquired. But, when specifying -mod=readonly, I’m getting:

go: updates to go.mod needed, disabled by -mod=readonly

I don’t know that go install should error out here. Certainly it could just continue with whatever changes needed just being retained in memory? As a user, I’m interested in the binary installation, not the side effect updates.

Thanks for considering,

@bcmills bcmills added modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jul 28, 2019
@bcmills bcmills added this to the Go1.14 milestone Jul 28, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/204521 mentions this issue: cmd/go: default to mod=readonly when the go.mod file is read-only

gopherbot pushed a commit that referenced this issue Nov 1, 2019
Updates #30185
Updates #33326
Updates #34822

Change-Id: Ie13651585898d1bbbf4f779b97ee50b6c7e7ad50
Reviewed-on: https://go-review.googlesource.com/c/go/+/204521
Run-TryBot: Bryan C. Mills <[email protected]>
Reviewed-by: Jay Conrod <[email protected]>
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/204878 mentions this issue: cmd/go: make commands other than 'tidy' prune go.mod less agressively

gopherbot pushed a commit that referenced this issue Nov 6, 2019
Updates #31870
Updates #33326
Fixes #34822

Change-Id: I1337f171133c20800eacc6b0955ede5a394ea7eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/204878
Run-TryBot: Bryan C. Mills <[email protected]>
Reviewed-by: Jay Conrod <[email protected]>
@bcmills
Copy link
Contributor

bcmills commented Nov 6, 2019

it fails to lock the module cache because it’s read-only:

That should be fixed by https://golang.org/cl/205637, which is now in.

@stapelberg, provided that the go.sum file is complete (or complete enough) and the go.mod file is consistent, this should now be fixed at head (and in Go 1.14 when that is released). Please give it a spin and let us know if there are any gaps remaining.

@bcmills bcmills closed this as completed Nov 6, 2019
@bcmills bcmills self-assigned this Nov 6, 2019
@bcmills bcmills modified the milestones: Backlog, Go1.14 Nov 6, 2019
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/210341 mentions this issue: cmd/go: include cfg.BuildModReason in 'import lookup disabled' errors

gopherbot pushed a commit that referenced this issue Dec 6, 2019
This location was missed in CL 204521.

Updates #33326
Updates #33848

Change-Id: I0ece6d9b37548d8abb54f79c69be5548a0428c76
Reviewed-on: https://go-review.googlesource.com/c/go/+/210341
Run-TryBot: Bryan C. Mills <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Jay Conrod <[email protected]>
@stapelberg
Copy link
Contributor Author

Thanks for the changes! Just got around to giving this a spin with the now-available Go 1.14 beta 1 release.

Unfortunately, I still get the same error message when running go install:

2019/12/25 20:38:56 build step 4 of 5: [/bin/sh -c GOSUMDB=off GOCACHE=/tmp/throwaway GOPATH=/ro/gopath GOPROXY=off  GOBIN=/dest/tmp//ro/fzf-amd64-v0.0.0-20190719042446-65773882505b-4/out/bin go install -mod=readonly -v ]
go: updates to go.mod needed, disabled by -mod=readonly

Running go mod tidy before gets the go install command to work, but requires a writable GOPATH with a populated module cache (what I’m trying to get away from) because it does module lookup.

I compared the go.mod file before and after a go mod tidy run to see which changes the go tool thinks it needs:

--- before	2019-12-25 20:37:30.061450310 +0100
+++ after	2019-12-25 20:37:35.951455273 +0100
@@ -1,19 +1,11 @@
 module github.com/junegunn/fzf
 
 require (
-	github.com/gdamore/encoding v0.0.0-20151215212835-b23993cbb635 // indirect
 	github.com/gdamore/tcell v0.0.0-20170915061752-0a0db94084df
-	github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
-	github.com/jtolds/gls v4.2.1+incompatible // indirect
-	github.com/lucasb-eyer/go-colorful v0.0.0-20170223221042-c900de9dbbc7 // indirect
 	github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c
-	github.com/mattn/go-runewidth v0.0.0-20170201023540-14207d285c6c
+	github.com/mattn/go-runewidth v0.0.4
 	github.com/mattn/go-shellwords v1.0.3
-	github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
-	github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect
-	golang.org/x/crypto v0.0.0-20170728183002-558b6879de74
-	golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 // indirect
-	golang.org/x/text v0.0.0-20170530162606-4ee4af566555 // indirect
+	golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
 )
 
 replace golang.org/x/tools => golang.org/x/tools v0.0.0-20190311212946-11955173bddd
@@ -49,3 +41,5 @@
 replace github.com/gdamore/encoding => github.com/gdamore/encoding v1.0.0
 
 replace github.com/DATA-DOG/go-sqlmock => github.com/DATA-DOG/go-sqlmock v1.3.3
+
+go 1.13

Whole go.mod files:

before
module github.com/junegunn/fzf

require (
	github.com/gdamore/encoding v0.0.0-20151215212835-b23993cbb635 // indirect
	github.com/gdamore/tcell v0.0.0-20170915061752-0a0db94084df
	github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
	github.com/jtolds/gls v4.2.1+incompatible // indirect
	github.com/lucasb-eyer/go-colorful v0.0.0-20170223221042-c900de9dbbc7 // indirect
	github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c
	github.com/mattn/go-runewidth v0.0.0-20170201023540-14207d285c6c
	github.com/mattn/go-shellwords v1.0.3
	github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
	github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect
	golang.org/x/crypto v0.0.0-20170728183002-558b6879de74
	golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 // indirect
	golang.org/x/text v0.0.0-20170530162606-4ee4af566555 // indirect
)

replace golang.org/x/tools => golang.org/x/tools v0.0.0-20190311212946-11955173bddd

replace golang.org/x/text => golang.org/x/text v0.3.2

replace golang.org/x/sys => golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b

replace golang.org/x/sync => golang.org/x/sync v0.0.0-20190423024810-112230192c58

replace golang.org/x/net => golang.org/x/net v0.0.0-20190724013045-ca1201d0de80

replace golang.org/x/crypto => golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2

replace github.com/smartystreets/goconvey => github.com/smartystreets/goconvey v0.0.0-20190710185942-9d28bd7c0945

replace github.com/smartystreets/assertions => github.com/smartystreets/assertions v1.0.1

replace github.com/mattn/go-shellwords => github.com/mattn/go-shellwords v1.0.5

replace github.com/mattn/go-runewidth => github.com/mattn/go-runewidth v0.0.4

replace github.com/mattn/go-isatty => github.com/mattn/go-isatty v0.0.8

replace github.com/lucasb-eyer/go-colorful => github.com/lucasb-eyer/go-colorful v1.0.2

replace github.com/jtolds/gls => github.com/jtolds/gls v4.20.0+incompatible

replace github.com/gopherjs/gopherjs => github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c

replace github.com/gdamore/tcell => github.com/gdamore/tcell v1.1.4

replace github.com/gdamore/encoding => github.com/gdamore/encoding v1.0.0

replace github.com/DATA-DOG/go-sqlmock => github.com/DATA-DOG/go-sqlmock v1.3.3
after
module github.com/junegunn/fzf

require (
	github.com/gdamore/tcell v0.0.0-20170915061752-0a0db94084df
	github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c
	github.com/mattn/go-runewidth v0.0.4
	github.com/mattn/go-shellwords v1.0.3
	golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
)

replace golang.org/x/tools => golang.org/x/tools v0.0.0-20190311212946-11955173bddd

replace golang.org/x/text => golang.org/x/text v0.3.2

replace golang.org/x/sys => golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b

replace golang.org/x/sync => golang.org/x/sync v0.0.0-20190423024810-112230192c58

replace golang.org/x/net => golang.org/x/net v0.0.0-20190724013045-ca1201d0de80

replace golang.org/x/crypto => golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2

replace github.com/smartystreets/goconvey => github.com/smartystreets/goconvey v0.0.0-20190710185942-9d28bd7c0945

replace github.com/smartystreets/assertions => github.com/smartystreets/assertions v1.0.1

replace github.com/mattn/go-shellwords => github.com/mattn/go-shellwords v1.0.5

replace github.com/mattn/go-runewidth => github.com/mattn/go-runewidth v0.0.4

replace github.com/mattn/go-isatty => github.com/mattn/go-isatty v0.0.8

replace github.com/lucasb-eyer/go-colorful => github.com/lucasb-eyer/go-colorful v1.0.2

replace github.com/jtolds/gls => github.com/jtolds/gls v4.20.0+incompatible

replace github.com/gopherjs/gopherjs => github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c

replace github.com/gdamore/tcell => github.com/gdamore/tcell v1.1.4

replace github.com/gdamore/encoding => github.com/gdamore/encoding v1.0.0

replace github.com/DATA-DOG/go-sqlmock => github.com/DATA-DOG/go-sqlmock v1.3.3

go 1.13

I’m not sure why the Go tool thinks it needs to update anything—I thought fully specifying the versions using replace directives should have been enough.

Let me know if I should file a separate issue for this, but the intention and steps to reproduce are still the same :)

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/219237 mentions this issue: cmd/go: eliminate empty '()' when passing -mod=readonly explicitly to 'go list'

gopherbot pushed a commit that referenced this issue Feb 12, 2020
… 'go list'

Discovered while investigating #37197.

Updates #33326
Updates #34822

Change-Id: I38b136a4ee762a580a554125066b9778491295f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/219237
Run-TryBot: Bryan C. Mills <[email protected]>
Reviewed-by: Michael Matloob <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
@golang golang locked and limited conversation to collaborators Feb 11, 2021
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants