Compile rust src fail due to protoc

I want to compile anki/rslib for use,yet encounter protoc compile error.
on windows platform,rust version 1.65.0
HEAD HASH e3c3405f09d80219f56d46fa05bdd349422f3853 (after 2.1.54)

I think the following info is important.Much appreciated if someone could tell me how to fix it.

"protoc failed: anki/backend.proto: This file contains proto3 optional fields, but --experimental_allow_proto3_optional was not set.\r\n" }', 
Caused by:
  process didn't exit successfully: `D:\software\vscode_project\anki_sync\anki-sync-server-rs\anki\target\release\build\anki-8aa46e32a12d7b2a\build-script-main` (exit code: 101)
  --- stdout
  cargo:rerun-if-changed=../proto\anki\backend.proto
  cargo:rerun-if-changed=../proto\anki\cards.proto
  cargo:rerun-if-changed=../proto\anki\card_rendering.proto
  cargo:rerun-if-changed=../proto\anki\collection.proto
  cargo:rerun-if-changed=../proto\anki\config.proto
  cargo:rerun-if-changed=../proto\anki\deckconfig.proto
  cargo:rerun-if-changed=../proto\anki\decks.proto
  cargo:rerun-if-changed=../proto\anki\generic.proto
  cargo:rerun-if-changed=../proto\anki\i18n.proto
  cargo:rerun-if-changed=../proto\anki\import_export.proto
  cargo:rerun-if-changed=../proto\anki\links.proto
  cargo:rerun-if-changed=../proto\anki\media.proto
  cargo:rerun-if-changed=../proto\anki\notes.proto
  cargo:rerun-if-changed=../proto\anki\notetypes.proto
  cargo:rerun-if-changed=../proto\anki\scheduler.proto
  cargo:rerun-if-changed=../proto\anki\search.proto
  cargo:rerun-if-changed=../proto\anki\stats.proto
  cargo:rerun-if-changed=../proto\anki\sync.proto
  cargo:rerun-if-changed=../proto\anki\tags.proto
  Running: "C:\\Program Files\\Git\\usr\\bin\\protoc.exe" "--include_imports" "--include_source_info" "-o" "C:\\Users\\Admin\\AppData\\Local\\Temp\\prost-buildFfmYoy\\prost-descriptor-set" "-I" "../proto" "../proto\\anki\\backend.proto" "../proto\\anki\\cards.proto" "../proto\\anki\\card_rendering.proto" "../proto\\anki\\collection.proto" "../proto\\anki\\config.proto" "../proto\\anki\\deckconfig.proto" "../proto\\anki\\decks.proto" "../proto\\anki\\generic.proto" "../proto\\anki\\i18n.proto" "../proto\\anki\\import_export.proto" "../proto\\anki\\links.proto" "../proto\\anki\\media.proto" "../proto\\anki\\notes.proto" "../proto\\anki\\notetypes.proto" "../proto\\anki\\scheduler.proto" "../proto\\anki\\search.proto" "../proto\\anki\\stats.proto" "../proto\\anki\\sync.proto" "../proto\\anki\\tags.proto"

  --- stderr
ther, error: "protoc failed: anki/backend.proto: This file contains proto3 optional fields, but --experimental_allow_proto3_optional was not set.\r\n" }', rslib\build\protobuf.rs:128:10  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

I think I have fixed this error.just pass that argument to protoc.
anki/rslib/build/protobuf.rs:107

 let mut config = prost_build::Config::new();
    config
     .protoc_arg("--experimental_allow_proto3_optional")

Your protoc.exe is old - if you install a newer version, that option should be on by default now.

Thanks for the reply.I’ll try your advice.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.