What did you do?
From a fresh fedora installation (Fedora release 30) I've just followed the quick start in the readme
RELEASE_VERSION=v0.9.0
$ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
$ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc
$ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc
KEY_ID=
$ gpg --recv-key "$KEY_ID"
$ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc
--> check ok
$ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu && sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/operator-sdk
$ dnf install -y git go mercurial bzr origin-clients dep
$ mkdir -p $HOME/projects/example.com/
$ cd $HOME/projects/example.com/
$ operator-sdk new memcached-operator
What did you expect to see?
Completion of the go scaffold setup
What did you see instead? Under which circumstances?
$ operator-sdk new memcached-operator
The cmd breaks with:
Error: dependency manager "modules" requires the flag --repo to be set if the working directory is not in $GOPATH/src. See "operator-sdk new -h"
I've tried
$ operator-sdk new memcached-operator --repo ./
but this breaks after a wile:
can't load package: package .//cmd/manager: non-canonical import path: ".//cmd/manager" should be "cmd/manager"
Environment
operator-sdk version: v0.9.0, commit: 560208dc998de497bbf59fea1b63426aec430934
go version go1.12.7 linux/amd64
Client Version: version.Info{Major:"1", Minor:"10+", GitVersion:"v1.10.0+d4cacc0", GitCommit:"d4cacc0", GitTreeState:"clean", BuildDate:"2018-12-06T15:15:06Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0+d4cacc0", GitCommit:"d4cacc0", GitTreeState:"clean", BuildDate:"2019-07-08T19:16:39Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}
Kubernetes cluster kind: OKD
Are you writing your operator in ansible, helm, or go?
go
Possible Solution
maybe define the go path... but this is not more required for newer go versions
Additional context
@p-sforza you should include --repo github.com/example/my-operator when running operator-sdk new.
The reason is - when you run outside the GOPATH, the SDK can't figure out the import path to use for the operator so you have to specify --repo explicitly.
--repo ./ gives you an error because .//something is not a valid Go import path.
@johananl well I think it seems to be a bit more peculiar in my case
[root@fed-30-0 src]# pwd
/root/go/src
[root@fed-30-0 src]# echo $GOPATH
/root/go
[root@fed-30-0 src]# operator-sdk new test-operator
INFO[0000] Creating new Go operator 'test-operator'.
Error: dependency manager "modules" requires working directory to be in $GOPATH/src and GO111MODULE=on, or outside of $GOPATH/src and GO111MODULE="on", "auto", or unset
Usage:
operator-sdk new[flags] Flags:
< snipped >
then the same for dir >/root/go/
[root@fed-30-0 src]# operator-sdk version
operator-sdk version: v0.9.0, commit: 560208dc998de497bbf59fea1b63426aec430934
Any good thought ?
Hi johananl,
I tried running "operator-sdk new app-operator" on GOPATH/src path and it worked fine.
My environment:
go version go1.12.7 linux/amd64
operator-sdk version: v0.9.0-17-gd6e1aba, commit: d6e1aba9fa512ff9d441b648f548399c86929643
Best regards
@nzaharioudakis you have two options:
Option 1
cd $GOPATH/src/github.com/yourgithubuser
export GO111MODULE=on
operator-sdk new test-operator
Option 2
cd /tmp/somedir
operator-sdk new test-operator --repo github.com/yourgithubuser/test-operator
I personally use option 2.
~You can check how GO111MODULE is set for you using go env GO111MODULE (nothing means unset).~
EDIT: Actually GO111MODULE isn't included in go env, so env | grep GO111MODULE could be useful.
I tried running "operator-sdk new app-operator" on GOPATH/src path and it worked fine.
@vincmarz cool. I'm guessing you have GO111MODULE=on then?
@johananl Yes, I did it
@johananl Option #2 always wins !
Perhaps an idea to include it in the error message next time. Thanks a bunch !
@nzaharioudakis you have two options:
Option 1
cd $GOPATH/src/github.com/yourgithubuser export GO111MODULE=on operator-sdk new test-operatorOption 2
cd /tmp/somedir operator-sdk new test-operator --repo github.com/yourgithubuser/test-operatorI personally use option 2.
~You can check how
GO111MODULEis set for you usinggo env GO111MODULE(nothing means unset).~EDIT: Actually
GO111MODULEisn't included ingo env, soenv | grep GO111MODULEcould be useful.
Does this mean that the dependecies for the project will be in $GOPATH/src/github.com/yourgithubuser/test-operator
@Katiyman If I understood your question correctly, when using Go modules any dependencies are downloaded to $GOPATH/pkg/mod.
Most helpful comment
@nzaharioudakis you have two options:
Option 1
Option 2
I personally use option 2.
~You can check how
GO111MODULEis set for you usinggo env GO111MODULE(nothing means unset).~EDIT: Actually
GO111MODULEisn't included ingo env, soenv | grep GO111MODULEcould be useful.