-
Notifications
You must be signed in to change notification settings - Fork 407
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
Import paths aren't support with go modules #129
Comments
This works for me:
There are some caveats though. With go modules, we don't have a global root for searching for modules anymore, so we first check to see if we're in a go modules project via:
Then we check to see if the path matches what's in your go.mod file here with a simple prefix heuristic. That generally works, but you might be hitting #106 |
Does your example only work then because you are building ko from the ko repo? |
Yes -- if your current working directory is using go modules, we use the go.mod file essentially as your go root. Building a different project used to work because we could assume any package was at a specific place on your GOPATH. With modules, we can't rely on that. I think my initial PR would fall back to GOPATH to look for a package, but we decided that would be confusing: #60 (comment) If you have a reasonable use case for it, I'm not opposed to it. When we implemented support for go modules, we weren't really sure how people were using modules with multiple repos. |
I think my expectation was similar to when I use the |
This seems like something we could support in strict mode where we know a given string represents a go package, but without it this would probably be too expensive.
|
I pushed the simplest thing I could imagine to try to fix this, but I haven't tested it extensively... want to give #139 a try? |
Hm, it didn't seem to help. I'm still getting the same error. |
I think I'm mixing three related but not quite exactly the same issues... I just pushed bc8f117 which would fix your issue with |
It seems to get further however I still get an error: $ cat go.mod
module github.com/x/x
go 1.14
require github.com/google/ko v0.4.0 // indirect
$ ko publish github.com/google/ko/cmd/ko
2020/03/11 22:41:24 Using base gcr.io/distroless/static:latest for github.com/google/ko/cmd/ko
2020/03/11 22:41:27 Building github.com/google/ko/cmd/ko
2020/03/11 22:41:42 failed to publish images: error building "github.com/google/ko/cmd/ko": unmatched importPackage with gomodules |
This issue is stale because it has been open for 90 days with no |
I tried the following while in a repo with go modules enabled:
However I got the following error:
I can work around it by doing:
However, this is not intuitive and it does not respect the given version found in my
go.mod
file.The text was updated successfully, but these errors were encountered: