cunarist / rinf

Rust for native business logic, Flutter for flexible and beautiful GUI
MIT License
1.99k stars 72 forks source link

Add the possibility to enable the --experimental_allow_proto3_optional feature of protobuf #237

Closed ALEZ-DEV closed 11 months ago

ALEZ-DEV commented 11 months ago

Report

Hey,

I have an issue with protobuf, because I use the optional feature on my proto files, because of rust optional and all... When I compile on my windows computer all compile fine, too in the CI I made for windows compilation, but when I try to compile to my linux CI to make a linux and apk executable, I get this error :

Verifying `protoc-gen-prost` for Rust. This might take a while if there are new updates to be installed.
some_file.proto: This file contains proto3 optional fields, but --experimental_allow_proto3_optional was not set.

Unhandled exception:
Exception: Could not compile `.proto` files into Rust
#0      _generateMessageCode (file:///home/runner/.pub-cache/hosted/pub.dev/rinf-4.15.2/bin/rinf.dart:449:7)
<asynchronous suspension>
#1      main (file:///home/runner/.pub-cache/hosted/pub.dev/rinf-4.15.2/bin/rinf.dart:20:7)
<asynchronous suspension>

Building Linux application...

and some code error there because it doesn't find the rust file generated by protobuf...

Suggestion

That will be cool if you can add the --experimental_allow_proto3_optional features, this can be something like that :

rinf message --experimental_allow_proto3_optional

I will wait for your response to continue the CI

Thank you for your hard work on this project !

temeddix commented 11 months ago

Hi @ALEZ-DEV , thank you for the report :)

Could you share the content of your .proto file with optional fields, so that I can take a look? Maybe this can be done easily as we only need to add that argument to the protobuf command.

ALEZ-DEV commented 11 months ago

There is my proto file :

syntax = "proto3";
package librqbit_torrent;

message TorrentAddInfo {
    string magnet_link = 1;
}

message TorrentAddedInfo {
    bool has_been_added = 1;
}

message CurrentTorrentDownloadInfo {
    repeated TorrentState torrents_state = 1;
}

message TorrentState {
    optional int64 id = 1;
    optional double pourcent = 2;
    optional string progress = 3;
    optional string remaining = 4;
    optional string total = 5;
    optional double downspeed = 6;
    optional int64 peers = 7;
    TorrentStartState state = 8;
    optional string name = 9;
}

enum TorrentStartState {
    Initializing = 0;
    Running = 1;
}

message newSessionInfo {
    string directory_path = 1;
}
temeddix commented 11 months ago

Hmm, at least this .proto code works well on Windows, as you said.

I dived into the Protobuf documentation and found out that from protoc version 3.15, we do not need that --experimental_allow_proto3_optional argument:

On your Linux machine, could you check that your protoc version is 3.15 or higher, with this command?

protoc --version
ALEZ-DEV commented 11 months ago

oh, you're right, my version was outdated : libprotoc 3.12.4

I will see how to update it Thank you for your help !