-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
No GOPATH environment variable breaks code generators #359
Comments
I like the option 2 that you suggested. Do you mind sharing the value for parameter for If you are interested, this is where additional argument can be supplied to fix it. https://github.com/kubernetes-sigs/controller-tools/blob/master/pkg/scaffold/manager/apis.go#L41 |
When there is no GOPATH, deepcopy-gen must set the output base. Use the build package to determine what the appropriate GOPATH is regardless. Fixes kubernetes-sigs#359
When there is no GOPATH, deepcopy-gen must set the output base. Use the build package to determine what the appropriate GOPATH is regardless. Fixes kubernetes-sigs#359
So the problem is that there are other go generate stanzas that are outside the control of kubebuiler. So I am running without a GOPATH, but I don't get the failures above. |
@fraenkel, I don't understand from your explanation why you don't experience the problem without a GOPATH, however, there are also a couple of other things that I don't understand:
|
Once I realized my mistake, I reworked the PR to only add the base when the GOPATH was missing. At the time I also noticed that the generate line wasn't changing. So I decided to replicate your original issue first so I could see where things were really breaking. But that too proved to be a problem. I was running with no GOPATH but not hitting any issue. |
hmm... interesting @fraenkel, I wonder what the difference is in our setups, I have the following things installed:
And I'm running Arch Linux if that makes any difference. |
Just tried it again.
Using Go 1.10.3 on Ubuntu 18.04. |
@fraenkel , I reproduced the issue on Ubuntu 18.04. Here is a
And here is the last part of the provisioning output:
|
That helped. The issue is I wasn't running make twice to see the actual error. If I run make once, the file is generated in the wrong location. |
Due to a poor choice of dependencies in the controller-tools -> inflect -> gobuffalo, there is an init() method which sets the GOPATH when its missing. The only solution is to compute the relative path to the root of the correct GOPATH entry which would allow movement of the tree. The downside is that this will break if and when modules are supported. |
that's as far as I got with it by now as well :) hm, it looks to me that we should consider two options:
|
Actually using -o is pretty tricky. If you are outside your GOPATH, I am not entirely sure what it will determine the full path from the -o location should look like. |
I just faced this, and the other issues about paths being all weird (such as NEEDing to be under +1 for failing fast in the Makefile. As a pure user, and not contributor, I can and will fix everything you want in my environment, so long as I know what you want. :-) I just always want to know what the tool needs and I'll go make it happen. |
I agree with @archisgore, why not just abort early instead of all the mental gymnastics? |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
should be fixed a of v2.0.0, closing |
Problem
If one uses the default gopath at
$HOME/go
, and therefore does not set a GOPATH environment variable, the deepcopy-gen will save its output files into the wrong destination path.This is the output if one just tries to follow the quickstart without a defined GOPATH environment variable:
As one can see the output gets saved to
pkg/apis/ships/pkg/apis/ships
, so the relative output base is wrong.The deepcopygen command line is defined in the
pkg/apis/apis.go
like this:It is not setting the output base on the command line, which works like this according to the help:
As there is no GOPATH set, the default is the current working directory, and this is why there is the duplicate
pkg/apis/ships
path in the destination.Workaround:
Simply set your GOPATH environment variable like:
Possible Solutions:
go:generate
command line and add a-o
deepcopy-gen
? I don't think this is a good idea though, it's pretty clear how it should workThe text was updated successfully, but these errors were encountered: