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

option paths=source_relative:. causes import cycle loop #196

Closed
strobil opened this issue Nov 26, 2019 · 7 comments
Closed

option paths=source_relative:. causes import cycle loop #196

strobil opened this issue Nov 26, 2019 · 7 comments

Comments

@strobil
Copy link

strobil commented Nov 26, 2019

Command used for generating *twirp.go

protoc -I /usr/local/include/
-I $GOPATH/src
-I $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
-I .
-I tv_service
--go_out=plugins=grpc,paths=source_relative:.
--grpc-gateway_out=logtostderr=true,grpc_api_configuration=tv_service/tv_service.yaml,paths=source_relative:.
--twirp_out=paths=source_relative:.
tv_service/tv_service.proto

When i am trying to build project this error occurs:

import cycle not allowed
package gitlab.sweet.tv/go/tv_service
imports gitlab.sweet.tv/proto/tv_service
imports gitlab.sweet.tv/proto/tv_service

The reason is in generated file which contains this line, but it should not, because the package name is identical in both cases (tv_service)

import tv_service8 "gitlab.sweet.tv/proto/tv_service"

If i remove paths=source_relative:. the generated file does not contain this import line.

@spenczar
Copy link
Contributor

spenczar commented Dec 2, 2019

This is hard to debug without more detail. Can you share the .proto file you are using, or a stripped-down version of it that minimally reproduces your error?

@strobil
Copy link
Author

strobil commented Dec 3, 2019

@spenczar Yes, sure.

Untar these files and run go_generate.sh

proto2.tar.gz

@spenczar
Copy link
Contributor

spenczar commented Dec 3, 2019

Thanks, I'm able to reproduce your error. I'll isolate it into a test case and work on a fix.

@spenczar
Copy link
Contributor

spenczar commented Dec 3, 2019

@strobil can you test the branch 'fix_local_proto_imports' (#202) to confirm that it fixes your full build? It works for me locally.

@strobil
Copy link
Author

strobil commented Dec 6, 2019

@spenczar, how i can install a specific version of protoc-gen-twirp?

@spenczar
Copy link
Contributor

spenczar commented Dec 13, 2019

@strobil Something like this:

export GOPATH=$(mktemp -d)
mkdir -p $GOPATH/src/github.com/twitchtv/twirp
git clone https://github.com/twitchtv/twirp.git $GOPATH/src/github.com/twitchtv/twirp
cd $GOPATH/src/github.com/twitchtv/twirp
git checkout -b fix_local_proto_imports origin/fix_local_proto_imports
go build -o $HOME/protoc-gen-twirp $GOPATH/src/github.com/twitchtv/twirp

Now you'll have an updated version of protoc-gen-twirp in $HOME. Add $HOME to the front of your PATH, and then protoc should use it.

@dpolansky
Copy link
Contributor

Spencer's fix for this issue was released in v5.10.2.

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

3 participants