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

x/tools/gopls/internal/lsp/filecache: failures on android with read-only file system as of CL 443099 #57630

Closed
bcmills opened this issue Jan 5, 2023 · 6 comments
Assignees
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. OS-Android Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jan 5, 2023

https://build.golang.org/log/5b087fd350cb4eca1112dd3b79f8b74c1a2ef301:

2022/12/19 16:09:17 New session
	create_session=1
2022/12/19 16:09:17 go env for /data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175
(root /data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175)
(go version go version devel 0b2ad1d815ea8967c49b32d848b2992d0c588d88 android/386)
(valid build configuration = true)
(build flags: [])
GOSUMDB=sum.golang.org
GOINSECURE=
GOMOD=/data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175/go.mod
GOPRIVATE=
GOWORK=
GOMODCACHE=/data/local/tmp/go_android_exec/cmd.test-20630/gopath/pkg/mod
GOPROXY=http://gk3-services-nap-jetxd907-8f582974-4wn4.c.symbolic-datum-552.internal:30157
GOPATH=/data/local/tmp/go_android_exec/cmd.test-20630/gopath
GOROOT=/data/local/tmp/go_android_exec/goroot
GOFLAGS=
GONOSUMDB=
GO111MODULE=
GONOPROXY=
GOCACHE=/data/local/tmp/go_android_exec/gocache

2022/12/19 16:09:17 go/packages.Load #1: err: exit status 2: stderr: go: no such tool "compile"

	snapshot=0
	directory=file:///data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175
	query=[builtin fake/...]
	packages=0
2022/12/19 16:09:17 initial workspace load failed: packages.Load error: err: exit status 2: stderr: go: no such tool "compile"

2022/12/19 16:09:17 workspace packages: diagnosing file:///data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175/go.mod: packages.Load error: err: exit status 2: stderr: go: no such tool "compile"

2022/12/19 16:09:17 errors loading workspace: packages.Load error: err: exit status 2: stderr: go: no such tool "compile"

	snapshot=0
	directory=file:///data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175
2022/12/19 16:09:17 go/packages.Load #2
	snapshot=2
	directory=file:///data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175
	query=[file=/data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175/fake.go]
	packages=1
2022/12/19 16:09:17 go/packages.Load #2
	snapshot=2
	directory=file:///data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175
	package="command-line-arguments"
	files=[/data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175/fake.go]
2022/12/19 16:09:17 go/packages.Load #2: updating metadata for 1 packages
2022/12/19 16:09:17 go/packages.Load #4
	snapshot=2
	directory=file:///data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175
	query=[file=/data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175/fake.go]
	packages=1
2022/12/19 16:09:17 go/packages.Load #4
	snapshot=2
	directory=file:///data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175
	package="command-line-arguments"
	files=[/data/local/tmp/go_android_exec/cmd.test-20630/fake3265390175/fake.go]
2022/12/19 16:09:17 go/packages.Load #4: updating metadata for 0 packages
2022/12/19 16:09:17 can't create cache: mkdir /.cache: read-only file system
exitcode=1
FAIL	golang.org/x/tools/gopls/internal/lsp/cmd	8.525s
…
2022/12/19 16:09:19 can't create cache: mkdir /.cache: read-only file system
exitcode=1
FAIL	golang.org/x/tools/gopls/internal/lsp/filecache	9.302s
@bcmills bcmills added OS-Android NeedsFix The path to resolution is known, but the work has not been done. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Jan 5, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jan 5, 2023
@bcmills
Copy link
Contributor Author

bcmills commented Jan 5, 2023

(CC @golang/android)

I'm not sure how it's ending up trying to create /.cache: it is using GOPLS_CACHE, then falling back to os.UserCacheDir(), and finally os.TempDir(). It seems plausible that neither $XDG_CACHE_HOME nor $HOME is defined on Android, but in that case os.userCacheDir() should be returning an error instead of /.cache.

(Maybe $HOME on the device is being explicitly set to /?)

@adonovan
Copy link
Member

adonovan commented Jan 5, 2023

I agree with your analysis., and this testdata file is evidence that HOME is indeed (or once was) set to /. But I would argue that setting HOME to / without setting XDG_CACHE_HOME is a misconfiguration since it will cause os.UserCacheDir() to fail always.

Or are applications supposed to substitute /tmp/whatever when UserCacheDir fails? That would seem to violate the spirit of "[Applications] should create their own application-specific subdirectory within [UserCacheDir] and use that."

@bcmills
Copy link
Contributor Author

bcmills commented Jan 5, 2023

I don't see any tests at all that exercise os.UserCacheDir. Is that really possible? 😵‍💫

(https://cs.opensource.google/search?q=UserCacheDir&ss=go%2Fgo)

@bcmills
Copy link
Contributor Author

bcmills commented Jan 5, 2023

Indeed, it seems that UserCacheDir lacks tests entirely (filed as #57638). Perhaps it should return an error if the chosen directory is not writable, so that the caller can fall back to something more reasonable.

@adonovan
Copy link
Member

adonovan commented Jan 5, 2023

In that case it should probably attempt to create the cache directory.

Ja7ad added a commit to Ja7ad/go that referenced this issue Jan 18, 2023
error UserCacheDir skipped and empty string cache dir got fatal.

for test write permission in cache dir add mkdir temp.

Fixes golang#57638 golang#57630
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.12.0 Jan 25, 2023
@findleyr
Copy link
Contributor

@adonovan is there anything to do here, following https://go.dev/cl/460917? Can we close?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. OS-Android Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants