grpc / grpc/grpc-rust

Proto package name must match filename

Open
#1,007 11 comments 3 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

## Bug Report

### Version

```
% cargo tree | grep tonic
├── tonic v0.7.2
└── tonic-build v0.7.2
```

### Platform

```
% uname -a
Darwin MacBook-Pro 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64
```

### Description

`helloworld.proto`:

```
syntax = "proto3";
package helloworld;

import "proto/request.proto";

// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (r.HelloRequest) returns (HelloReply) {}
}

// The response message containing the greetings
message HelloReply {
string message = 1;
}
```

`request.proto`:

```
syntax = "proto3";

package r;

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
```

This gives a lot of errors that all look like:

```
error[E0433]: failed to resolve: could not find `r` in the crate root
--> /Users/alelazar/Documents/helloworld-tonic/target/debug/build/helloworld-tonic-33d7ab904b011773/out/helloworld.rs:75:60
|
75 | request: impl tonic::IntoRequest,
| ^ could not find `r` in the crate root
```

This works fine if I change the package from `r` to `request` (and update relevant references)

Things also work fine if the packages match - changing `r` to `helloworld`.

There is a decent chance I'm just doing things wrong.

### Side Note

It would be nice if we could eschew package names altogether - in other languages, I normally only see packages specified in order to differentiate similarly named types. Rust/tonic is forcing me to update cross language proto use to have packages.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.