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

vfsgen broken after upgrading to golang 1.13 #75

Closed
veqryn opened this issue Nov 16, 2019 · 2 comments
Closed

vfsgen broken after upgrading to golang 1.13 #75

veqryn opened this issue Nov 16, 2019 · 2 comments

Comments

@veqryn
Copy link

veqryn commented Nov 16, 2019

We run vfsgen inside of a docker container. Previously that docker container was based on golang 1.12, but we upgrade it to 1.13 today.
After upgrading to golang 1.13, vfsgen started failing out:

go: github.com/ReturnPath/zzz@v0.0.0-20190917161345-2ad29436c755: invalid version: git fetch -f https://github.com/ReturnPath/zzz refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/595ef178a519bba79a7580920dc80e819bacb31e39f9842a1de283c683f92cd1: exit status 128:
     fatal: could not read Username for 'https://github.com': terminal prompts disabled

Our project has several golang modules it depends on that are private, with the obfuscated https://github.com/xxx/zzz being one of them. We use go mod vendor to commit them to the repo.

Why is vfsgen running go get or git fetch or anything like that?

vfsgen shouldn't be getting my source files, when they are all right there already.

What is going on, and how to solve it?

@dmitshur
Copy link
Member

dmitshur commented Nov 16, 2019

vfsgen itself doesn't do go get. Are you using the vfsgendev command?

I suspect the problem is that the vfsgendev command was designed to work in GOPATH mode and no longer works in module mode in some situations. It tries to execute the code generation program in a temporary directory, which means it no longer has access to your main module. It needs to be reworked to be compatible with module mode.

If that is the problem, then I'd suggest using vfsgen yourself directly in your project rather than relying on the vfsgendev helper.

It's possible the reason you started seeing the problem when going from Go 1.12 to 1.13 is because it started to use module mode in more situations (see https://golang.org/doc/go1.13#modules). So you can also consider forcing GOPATH mode explicitly when using vfsgendev, but that is of course not a good long term solution.

@veqryn
Copy link
Author

veqryn commented Mar 13, 2020

This was fixed by adding -mod=vendor to the run statement:
//go:generate go run -mod=vendor <etc...>

@veqryn veqryn closed this as completed Mar 13, 2020
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

No branches or pull requests

2 participants