viper: io/fs: package io/fs is not in GOROOT

Expected behavior (what you expected to happen):

go mod tidy to work when viper 1.8.0 is imported

Actual behavior (what actually happened):

Fails with the error:

gitlab.eng.com/xxx/zzz/cmd imports
	github.com/spf13/viper imports
	github.com/spf13/afero imports
	io/fs: package io/fs is not in GOROOT (/usr/local/go/src/io/fs)
gitlab.eng.com/xxx/zzz/cmd imports
	github.com/spf13/viper imports
	github.com/spf13/afero tested by
	github.com/spf13/afero.test imports
	testing/fstest: package testing/fstest is not in GOROOT (/usr/local/go/src/testing/fstest)

Environment:

  • Viper version: 1.8.0
  • go version: go1.15 darwin/amd64

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 16

Commits related to this issue

Most upvoted comments

@DarthPestilane you could try replacing the afero version. I don’t think we use anything from the new 1.6.0 release:

$ cat go.mod 
module test

go 1.15

require github.com/spf13/viper v1.8.1

replace github.com/spf13/afero => github.com/spf13/afero v1.5.1

Keep in mind that Viper (similarly to Go itself) supports the two latest minor Go versions. (Yes, the readme is incorrect and needs updating)

@arriqaaq @kotyara85 @tmac33 @rengas @moreandres Can someone confirm that upgrading to 1.15.10 resolves the issue?

yes, upgrading can resolve this. Thank you, @sagikazarmark

I’m able to reproduce this issue on Go 1.15.5, but I can no longer reproduce it after Go 1.15.10, so upgrading to that (or later) version should fix the problem.

References:

Hey @sagikazarmark

This does not happen on a go mod init

It just fails on go mod tidy

Upgrade to go1.15.10 to solve this? I’m using go1.14.14, ran into this issue, and I cannot upgrade the golang version. Is there any way to solve this without upgrade golang version? Now I have to use logrus@v1.7.1 instead, a downgrade… 😦

Cool! Please upgrade to a newer version then.