Skip to content

Error occurs when run protobuild with descriptors configs #8

@tossmilestone

Description

@tossmilestone

When running go list ./...|grep -v vendor|xargs protobuild under the protobuild package path, get errors:

protoc -I.:/home/user/go/src:/usr/local/include --include_imports --descriptor_set_out=/tmp/descriptors.pb-471601849 --go_out=plugins=grpc,import_path=github.com/stevvooe/protobuild/examples/foo,Mgogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto,Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor,Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types:/home/fly__fish/go/src /home/user/go/src/github.com/stevvooe/protobuild/examples/foo/foo.proto
/usr/local/include/google/protobuf/descriptor.proto: File does not reside within any path specified using --proto_path (or -I).  You must specify a --proto_path which encompasses this file.  Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).
2017/08/06 11:37:48 exit status 1

The protoc version is libprotoc 3.3.0.

According to the error message, I add -I /usr/local/include/google/protobuf to the descriptors.go file as:

func (d *descriptorSet) marshalTo(w io.Writer) error {
	p, err := proto.Marshal(&d.merged)
	if err != nil {
		return err
	}

	args := []string{
		"protoc",
		"--decode",
		"google.protobuf.FileDescriptorSet",

		// TODO(stevvooe): Come up with better way to resolve this path.
		"/usr/local/include/google/protobuf/descriptor.proto",
		"-I",
		"/usr/local/include/google/protobuf",
	}

	cmd := exec.Command(args[0], args[1:]...)
	cmd.Stdin = bytes.NewReader(p)
	cmd.Stdout = w
	cmd.Stderr = os.Stderr

	return cmd.Run()
}

And everything goes fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions