fzyzcjy/flutter_rust_bridge

Nothing is generated for dart wire class triggered

Opened this issue · 5 comments

Describe the bug

We make use of flutter_rust_bridge version 1.82.6. For reasons as of yet unknown, code generation stopped working with this error message:

An error occurred: Nothing is generated for dart wire class. Maybe you forget to put code like mod the_generated_bridge_code; to your lib.rs?

Steps to reproduce

  1. Possibly relevant that I run Rust 1.83 on Arch Linux (btw)?
  2. git clone git@github.com:MinBZK/nl-wallet.git
  3. cd nl-wallet
  4. cargo run --manifest-path wallet_core/flutter_rust_bridge_codegen/Cargo.toml
  5. Observe error (see logs below)

Logs

RUST_BACKTRACE=full RUST_LOG=debug cargo run --manifest-path wallet_core/flutter_rust_bridge_codegen/Cargo.toml
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `wallet_core/flutter_rust_bridge_codegen/target/debug/flutter_rust_bridge_codegen`
the path is "/home/rubin/Source/ICTU/wallet/wallet_core/flutter_rust_bridge_codegen/../../wallet_app/ios/Runner/bridge_generated.h"
thread 'main' panicked at src/main.rs:51:48:
called `Result::unwrap()` on an `Err` value: Nothing is generated for dart wire class. Maybe you forget to put code like `mod the_generated_bridge_code;` to your `lib.rs`?

Stack backtrace:
   0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
             at /home/rubin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.86/src/backtrace.rs:27:14
   1: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
             at /home/rubin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:2010:27
   2: lib_flutter_rust_bridge_codegen::frb_codegen_multi
             at /home/rubin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-1.82.6/src/lib.rs:76:5
   3: lib_flutter_rust_bridge_codegen::frb_codegen
             at /home/rubin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-1.82.6/src/lib.rs:37:5
   4: flutter_rust_bridge_codegen::main
             at ./wallet_core/flutter_rust_bridge_codegen/src/main.rs:51:5
   5: core::ops::function::FnOnce::call_once
             at /home/rubin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
   6: std::sys::backtrace::__rust_begin_short_backtrace
             at /home/rubin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:154:18
   7: std::rt::lang_start::{{closure}}
             at /home/rubin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:195:18
   8: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/ops/function.rs:284:13
   9: std::panicking::try::do_call
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:557:40
  10: std::panicking::try
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:520:19
  11: std::panic::catch_unwind
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panic.rs:358:14
  12: std::rt::lang_start_internal::{{closure}}
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/rt.rs:174:48
  13: std::panicking::try::do_call
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:557:40
  14: std::panicking::try
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:520:19
  15: std::panic::catch_unwind
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panic.rs:358:14
  16: std::rt::lang_start_internal
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/rt.rs:174:20
  17: std::rt::lang_start
             at /home/rubin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:194:17
  18: main
  19: <unknown>
  20: __libc_start_main
  21: _start
stack backtrace:
   0:     0x599897c99c6a - std::backtrace_rs::backtrace::libunwind::trace::h5a5b8284f2d0c266
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x599897c99c6a - std::backtrace_rs::backtrace::trace_unsynchronized::h76d4f1c9b0b875e3
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x599897c99c6a - std::sys::backtrace::_print_fmt::hc4546b8364a537c6
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/sys/backtrace.rs:66:9
   3:     0x599897c99c6a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h5b6bd5631a6d1f6b
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/sys/backtrace.rs:39:26
   4:     0x599897cc2123 - core::fmt::rt::Argument::fmt::h270f6602a2b96f62
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/fmt/rt.rs:177:76
   5:     0x599897cc2123 - core::fmt::write::h7550c97b06c86515
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/fmt/mod.rs:1186:21
   6:     0x599897c96613 - std::io::Write::write_fmt::h7b09c64fe0be9c84
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/io/mod.rs:1839:15
   7:     0x599897c99ab2 - std::sys::backtrace::BacktraceLock::print::h2395ccd2c84ba3aa
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/sys/backtrace.rs:42:9
   8:     0x599897c9ac7c - std::panicking::default_hook::{{closure}}::he19d4c7230e07961
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:268:22
   9:     0x599897c9aac2 - std::panicking::default_hook::hf614597d3c67bbdb
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:295:9
  10:     0x599897c9b257 - std::panicking::rust_panic_with_hook::h8942133a8b252070
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:801:13
  11:     0x599897c9b0ea - std::panicking::begin_panic_handler::{{closure}}::hb5f5963570096b29
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:674:13
  12:     0x599897c9a149 - std::sys::backtrace::__rust_end_short_backtrace::h6208cedc1922feda
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/sys/backtrace.rs:170:18
  13:     0x599897c9ad7c - rust_begin_unwind
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:665:5
  14:     0x5998971fd880 - core::panicking::panic_fmt::h0c3082644d1bf418
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:74:14
  15:     0x5998971fdd06 - core::result::unwrap_failed::hd20b4aa073bda1e2
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/result.rs:1700:5
  16:     0x59989720019f - core::result::Result<T,E>::unwrap::h24330219b5f61b06
                               at /home/rubin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1104:23
  17:     0x59989720019f - flutter_rust_bridge_codegen::main::hf40ebb9cec9af3c5
                               at /home/rubin/Source/ICTU/wallet/wallet_core/flutter_rust_bridge_codegen/src/main.rs:51:5
  18:     0x5998971fe3ab - core::ops::function::FnOnce::call_once::h2b95131ff371e616
                               at /home/rubin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  19:     0x5998971fe36e - std::sys::backtrace::__rust_begin_short_backtrace::h836fadafac55b0c8
                               at /home/rubin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:154:18
  20:     0x5998971fed51 - std::rt::lang_start::{{closure}}::hd638c60f196eca46
                               at /home/rubin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:195:18
  21:     0x599897c90b4e - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hfdb85f4ee94732d3
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/ops/function.rs:284:13
  22:     0x599897c90b4e - std::panicking::try::do_call::h6e577310f330cbef
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:557:40
  23:     0x599897c90b4e - std::panicking::try::ha588d438267d2645
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:520:19
  24:     0x599897c90b4e - std::panic::catch_unwind::h429fda1e025f26d9
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panic.rs:358:14
  25:     0x599897c90b4e - std::rt::lang_start_internal::{{closure}}::h7b731265e841c4bf
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/rt.rs:174:48
  26:     0x599897c90b4e - std::panicking::try::do_call::hc0f6a675b7ae5a36
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:557:40
  27:     0x599897c90b4e - std::panicking::try::h4c93b7ff0671f1ff
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:520:19
  28:     0x599897c90b4e - std::panic::catch_unwind::hcc1e154961d16ce6
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panic.rs:358:14
  29:     0x599897c90b4e - std::rt::lang_start_internal::h1c66660c99c8424c
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/rt.rs:174:20
  30:     0x5998971fed2a - std::rt::lang_start::h7a0438420f00993b
                               at /home/rubin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:194:17
  31:     0x59989720028e - main
  32:     0x758de3317e08 - <unknown>
  33:     0x758de3317ecc - __libc_start_main
  34:     0x5998971fe285 - _start
  35:                0x0 - <unknown>

Expected behavior

Succesfully generated, valid .dart files.

Generated binding code

N/A

OS

Arch Linux, kernel 6.12.1

Version of flutter_rust_bridge_codegen

1.82.6

Flutter info

[✓] Flutter (Channel stable, 3.24.5, on Arch Linux 6.12.1-arch1-1, locale
    en_US.UTF-8)
    • Flutter version 3.24.5 on channel stable at
      /home/rubin/.local/share/flutterup
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (2 weeks ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version
    35.0.0)
    • Android SDK at /opt/android
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /opt/android
    • Java binary at: /usr/lib/jvm/java-17-jetbrains/bin/java
    • Java version OpenJDK Runtime Environment JBR-17.0.12+1-1087.25-jcef
      (build 17.0.12+1-b1087.25)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = chromium

[✓] Linux toolchain - develop for Linux desktop
    • clang version 18.1.8
    • cmake version 3.31.1
    • ninja version 1.12.1
    • pkg-config version 2.1.1

[✓] Android Studio (version 2024.2)
    • Android Studio at /opt/jetbrains-toolbox/apps/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      21.0.3+-12282718-b509.11)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
    • IntelliJ at /opt/jetbrains-toolbox/apps/intellij-idea-ultimate-2
    • Flutter plugin version 82.2.4
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (3 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android
      13 (API 33) (emulator)
    • Linux (desktop)              • linux         • linux-x64      • Arch
      Linux 6.12.1-arch1-1
    • Chrome (web)                 • chrome        • web-javascript • Chromium
      131.0.6778.85 Arch Linux

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Version of clang++

18.1.8

Additional context

# rustc --version
rustc 1.83.0 (90b35a623 2024-11-26)

Hi! Thanks for opening your first issue here! 😄

Note: I tried downgrading to rust 1.82, but while I did note the resulting binary running for a noticably longer time, the error message remains the same.

We make use of flutter_rust_bridge version 1.82.6

Firstly, compared to v1, v2 is much stronger, and thus I strongly suggest to upgrade to v2 :)

code generation stopped working

Since code generation did work before, I guess one approach is to bisect the environment. For example, ffigen version, etc.

Is there a way to get more verbose messaging? I did execute with RUST_LOG=debug, but it doesn't show any additional messages that give me a hint as to where the problem originates.

With regards to upgrading to v2, believe me, it's on the todo but not something we can do as-of-yet.

You can try to run frb by source code (cargo run ...), and then can add arbitrarily many println! here and there for debugging.

The v1 code is in: https://github.com/fzyzcjy/flutter_rust_bridge/tree/v1-master