Skip to content

"package io/fs is not in GOROOT" on Go 1.15 #480

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

Closed
zikaeroh opened this issue Nov 21, 2020 · 11 comments · Fixed by #481
Closed

"package io/fs is not in GOROOT" on Go 1.15 #480

zikaeroh opened this issue Nov 21, 2020 · 11 comments · Fixed by #481

Comments

@zikaeroh
Copy link
Contributor

Describe the Bug

golang-migrate no longer builds in Go 1.15 due to the addition of io/fs, imported via tests.

Steps to Reproduce
Steps to reproduce the behavior:

Add v4.14.0 to the project, then run go mod tidy. I get:

github.com/hortbot/hortbot/internal/db/migrations imports
	github.com/golang-migrate/migrate/v4/database/postgres tested by
	github.com/golang-migrate/migrate/v4/database/postgres.test imports
	github.com/golang-migrate/migrate/v4/source/file imports
	github.com/golang-migrate/migrate/v4/source/iofs imports
	io/fs: package io/fs is not in GOROOT (/usr/lib/go/src/io/fs)
github.com/hortbot/hortbot/internal/db/migrations imports
	github.com/golang-migrate/migrate/v4/database/postgres tested by
	github.com/golang-migrate/migrate/v4/database/postgres.test imports
	github.com/golang-migrate/migrate/v4/source/file imports
	github.com/golang-migrate/migrate/v4/source/iofs tested by
	github.com/golang-migrate/migrate/v4/source/iofs.test imports
	embed: package embed is not in GOROOT (/usr/lib/go/src/embed)

Expected Behavior

No output.

Migrate Version

v4.14.0

Loaded Source Drivers

N/A

Loaded Database Drivers

N/A

Go Version

go version go1.15.5 linux/amd64

Stacktrace

N/A

Additional context

N/A

@dhui
Copy link
Member

dhui commented Nov 21, 2020

Looks like modules ignore build constraints
For now use v4.13.0
I'll release v4.14.1 later that removes the iofs source driver until Go 1.16 is the minimum supported version by migrate

@zikaeroh
Copy link
Contributor Author

I don't think that's the whole issue. If you just clone this repo and run go mod tidy, it fails.

github.com/golang-migrate/migrate/v4/source/iofs imports
	io/fs: package io/fs is not in GOROOT (/usr/lib/go/src/io/fs)
github.com/golang-migrate/migrate/v4/source/iofs tested by
	github.com/golang-migrate/migrate/v4/source/iofs.test imports
	embed: package embed is not in GOROOT (/usr/lib/go/src/embed)

@zikaeroh
Copy link
Contributor Author

zikaeroh commented Nov 21, 2020

Unless I'm mistaken, the issue is that the iofs package is not buildable in Go 1.15. There are build tags in the file source package, but the iofs package needs build tags too, even if they just replace things with noops or panics (or nothing at all, which is likely best).

@wayneashleyberry
Copy link

I'm seeing the same issue in a project of mine, both go test and go build work but go mod tidy fails.

github.com/overhq/over-projects-api/pkg/migrator imports
	github.com/golang-migrate/migrate/v4/database/mysql tested by
	github.com/golang-migrate/migrate/v4/database/mysql.test imports
	github.com/golang-migrate/migrate/v4/source/file imports
	github.com/golang-migrate/migrate/v4/source/iofs imports
	io/fs: package io/fs is not in GOROOT (/usr/local/Cellar/go/1.15.5/libexec/src/io/fs)
github.com/overhq/over-projects-api/pkg/migrator imports
	github.com/golang-migrate/migrate/v4/database/mysql tested by
	github.com/golang-migrate/migrate/v4/database/mysql.test imports
	github.com/golang-migrate/migrate/v4/source/file imports
	github.com/golang-migrate/migrate/v4/source/iofs tested by
	github.com/golang-migrate/migrate/v4/source/iofs.test imports
	embed: package embed is not in GOROOT (/usr/local/Cellar/go/1.15.5/libexec/src/embed)

@ksegun
Copy link

ksegun commented Nov 21, 2020

We also make use of this library and this is breaking our builds because of the module dependencies we have to pin over 30+ repos to v4.13.0 is there an outlook for when v4.14.1 will be available?

@johejo
Copy link
Contributor

johejo commented Nov 21, 2020

I'm the author of the #472.
Sorry for breaking the builds of many users.
I made a Pull Request for revert.
Please wait for the next release by maintainer.

@zikaeroh
Copy link
Contributor Author

zikaeroh commented Nov 21, 2020

Regardless of the revert, when the package is reintroduced (which I would still do for 1.16), it will work with the build tags guarding the imports of io/fs itself. You probably don't need a full revert if you stick // +build go1.16 into the existing files in iofs and add a single file with:

// +build !go1.16

package iofs

That will guard its use in versions below 1.16.

@zikaeroh
Copy link
Contributor Author

Hm, I say that, but you've done that in iofs already...

@zikaeroh
Copy link
Contributor Author

Ugh, this is golang/go#40067. Sorry for the noise.

I guess this driver could live in another repo until 1.16 is the minimum. Going via http.FileSystem works as well, though is clearly an unnecessary dep.

@ksegun
Copy link

ksegun commented Nov 21, 2020

I'm the author of the #472.
Sorry for breaking the builds of many users.
I made a Pull Request for revert.
Please wait for the next release by maintainer.

Thank you so much, I know it was not your intent, and thank you for this library.

@dhui dhui closed this as completed in #481 Nov 22, 2020
@dhui
Copy link
Member

dhui commented Nov 22, 2020

Fixed in v4.14.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants