fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.12k stars 283 forks source link

[Bug] Running the cli tool throw an `Err` value: please add ffi to your dependencies #633

Closed wentao closed 1 year ago

wentao commented 2 years ago

Describe the bug

Install the tool with cargo install, then run the tool cli against an interface definition file. The execution failed with the following error

thread 'main' panicked at 'called Result::unwrap() on an Err value: please add ffi to your dependencies. (version >=2.0.1, <3.0.0)', /Users/wentao/.cargo/registry/src/github.com-1ecc6299db9ec823/flutter_rust_bridge_codegen-1.41.1/src/main.rs:24:43

Codegen logs with RUST_LOG=debug environment variable

[2022-08-17T01:20:56Z DEBUG flutter_rust_bridge_codegen] configs=[Opts { rust_input_path: "/Users/wentao/Code/app/xplat/src/api.rs", dart_output_path: "/Users/wentao/Code/app/lib/api_generated.dart", dart_decl_output_path: None, c_output_path: ["/Users/wentao/Code/app/ios/rust/ffi_bridge_generated.h"], rust_crate_dir: "/Users/wentao/Code/app/xplat", rust_output_path: "/Users/wentao/Code/app/xplat/src/bridge_generated.rs", class_name: "Xplat", dart_format_line_length: 80, skip_add_mod_to_lib: false, llvm_path: ["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/Program Files/LLVM", "C:/msys64/mingw64"], llvm_compiler_opts: "", manifest_path: "/Users/wentao/Code/app/xplat/Cargo.toml", dart_root: Some("/Users/wentao/Code/app"), build_runner: true, block_index: BlockIndex(0) }]
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/bridge_generated.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/api.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/api_internal.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/context.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/crypto.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/dao/mod.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/dao/group.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/dao/item.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/dao/membership.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/dao/sync_task.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/dao/user.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/errors.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/models.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/rpc/mod.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/rpc/blobs.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/rpc/friendships.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/rpc/groups.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/rpc/items.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/rpc/locations.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/rpc/members.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/rpc/posts.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/rpc/users.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "/Users/wentao/Code/app/xplat/src/schema.rs"
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(reset)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(auth)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(anonymous)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(init)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(get_credential)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(update_fcm)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(change_profile)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(create_group)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(create_chat)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(group_invite)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(group_join)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(sync_groups)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(member_remove)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(member_update)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(member_pin)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(fetch_members)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(create_item)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(create_reply)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(fetch_items)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(fetch_friends)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(blob_url_base)
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::tools] Guessing toolchain the runner is run into
[2022-08-17T01:20:56Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute command: bin=sh args=["-c", "flutter --version"] current_dir=None cmd="sh" "-c" "flutter --version"
[2022-08-17T01:20:57Z DEBUG lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "flutter --version" stdout=Flutter 3.0.5 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision f1875d570e (5 weeks ago) • 2022-07-13 11:24:16 -0700
    Engine • revision e85ea0e79c
    Tools • Dart 2.17.6 • DevTools 2.12.2
     stderr=
[2022-08-17T01:20:57Z DEBUG lib_flutter_rust_bridge_codegen::tools] Checking presence of ffi in dependencies at /Users/wentao/Code/app
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: please add ffi to your dependencies. (version >=2.0.1, <3.0.0)', /Users/wentao/.cargo/registry/src/github.com-1ecc6299db9ec823/flutter_rust_bridge_codegen-1.41.1/src/main.rs:24:43
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
frb_codegen exited with non-zero

To Reproduce

No response

Expected behavior

The script was executed under the flutter project directory which doesn't has any rust/dart/android source code. The program should not check the existence of ffi under that folder.

Generated binding code

No response

OS

MacOS

Version of flutter_rust_bridge_codegen

1.41.1

Flutter info

[✓] Flutter (Channel stable, 3.0.5, on macOS 12.5 21G72 darwin-x64, locale en-US)
    • Flutter version 3.0.5 at /Users/wentao/Library/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (5 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/wentao/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.70.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • iPhone 8 (mobile) • 79CDA6A2-CA5C-4AFF-9641-758F34328FCD • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator)
    • macOS (desktop)   • macos                                • darwin-x64     • macOS 12.5 21G72 darwin-x64
    • Chrome (web)      • chrome                               • web-javascript • Google Chrome 104.0.5112.79

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Version of clang++

No response

Version of ffigen

No response

Additional context

No response

fzyzcjy commented 2 years ago

The script was executed under the flutter project directory which doesn't has any rust/dart/android source code. The program should not check the existence of ffi under that folder.

Hmm @Roms1383 (who implemented that useful feature) what do you think?

Related: #613

Roms1383 commented 2 years ago

Ah indeed, the script probably looks where it's executed from. I have to run some errands in the coming days but I'll try to check it out (and fix it) by next week. @wentao is there any special reason why there's no flutter/dart file in your root? Would you mind showing how your project is laid out?

Roms1383 commented 2 years ago

As far as I understand it (waiting for @wentao for more context), there's a couple of ways to address this :

What do you think @fzyzcjy?

fzyzcjy commented 2 years ago

add a cli argument to disable dependencies checks, which leaves it up to the users to handle everything by themselves without hindering

This option LGTM, since it is an optional feature that is good to be enabled by default but acceptable to disable if the user knows what he is doing

wentao commented 2 years ago

I just ran the command line tool locally from HEAD and noticed the following error

`[2022-08-25T02:47:28Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute ffigen c_path=/var/folders/53/j6z_b9_s6tb79n5yr6p1fynr0000gn/T/.tmpolxQYj.h dart_path=/var/folders/53/j6z_b9_s6tb79n5yr6p1fynr0000gn/T/.tmp0yrJ7b llvm_path=["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/Program Files/LLVM", "C:/msys64/mingw64"] [2022-08-25T02:47:28Z DEBUG lib_flutter_rust_bridge_codegen::commands] ffigen config: output: '/var/folders/53/j6z_b9_s6tb79n5yr6p1fynr0000gn/T/.tmp0yrJ7b' name: 'XplatWire' description: 'generated by flutter_rust_bridge' headers: entry-points:

[2022-08-25T02:47:28Z DEBUG lib_flutter_rust_bridge_codegen::commands] ffigen config_file: NamedTempFile("/var/folders/53/j6z_b9_s6tb79n5yr6p1fynr0000gn/T/.tmpQa4PLP") [2022-08-25T02:47:28Z DEBUG lib_flutter_rust_bridge_codegen::tools] Guessing toolchain the runner is run into [2022-08-25T02:47:28Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute command: bin=sh args=["-c", "cd /Users/wentao/Code/app && flutter pub run ffigen --config \"/var/folders/53/j6z_b9_s6tb79n5yr6p1fynr0000gn/T/.tmpQa4PLP\""] current_dir=None cmd="sh" "-c" "cd /Users/wentao/Code/app && flutter pub run ffigen --config \"/var/folders/53/j6z_b9_s6tb79n5yr6p1fynr0000gn/T/.tmpQa4PLP\"" [2022-08-25T02:47:30Z WARN lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "cd /Users/wentao/Code/app && flutter pub run ffigen --config \"/var/folders/53/j6z_b9_s6tb79n5yr6p1fynr0000gn/T/.tmpQa4PLP\"" stdout= stderr=Could not find package "ffigen". Did you forget to add a dependency? pub finished with exit code 65

thread 'main' panicked at 'called Result::unwrap() on an Err value: ffigen failed: stderr: Could not find package "ffigen". Did you forget to add a dependency? pub finished with exit code 65

stdout: ', src/main.rs:24:43 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace frb_codegen exited with non-zero`

wentao commented 2 years ago

I have passed the skip_deps_check flag but somehow it still look for the dependency for some execution? This behavior is very different from what the cli tool used to be.

Please advice how to by pass this, or which version I can use to avoid running this issue.

fzyzcjy commented 2 years ago

I have passed the skip_deps_check flag but somehow it still look for the dependency for some execution?

How do you pass it? Could you please share the command

cc @Roms1383

wentao commented 2 years ago

RUST_LOG=debug flutter_rust_bridge_codegen --skip-deps-check --rust-input xplat/src/api.rs --dart-output lib/api_generated.dart -c ios/rust/ffi_bridge_generated.h

wentao commented 2 years ago

I just tried to use 1.30.0 version and got the following error message

[2022-08-25T03:28:46Z DEBUG lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "dart pub global list" stdout= stderr= thread 'main' panicked at 'called Result::unwrap() on an Err value: ffigen is not a command, or not executable.', src/main.rs:16:23 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Does cli require ffigen an executable command? How do I install one so the cli won't fail?

wentao commented 2 years ago

Now running version 1.28.1 and got some useful error messages:

[2022-08-25T03:32:14Z ERROR flutter_rust_bridge_codegen::commands] ffigen is not available, please run "dart pub global activate ffigen" first. frb_codegen exited with non-zero

[2022-08-25T03:33:09Z ERROR flutter_rust_bridge_codegen::commands] cbindgen is not a command, or not executable. Note: This command might be available via cargo, in which case it can be installed with:

    cargo install cbindgen

frb_codegen exited with non-zero

After installing ffigen and cbindgen, now everything works fine with version 1.28.1. Will check the latest version to see if it works.

fzyzcjy commented 2 years ago

Does cli require ffigen an executable command? How do I install one so the cli won't fail?

Yes it requires

wentao commented 2 years ago

Installed the 1.41.2 version from cargo install, and passed the skip_deps_check flag, still got the error of

[2022-08-25T03:43:19Z WARN lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "cd /Users/wentao/Code/app && flutter pub run ffigen --config \"/var/folders/53/j6z_b9_s6tb79n5yr6p1fynr0000gn/T/.tmpP7JOSu\"" stdout= stderr=Could not find package "ffigen". Did you forget to add a dependency? pub finished with exit code 65

thread 'main' panicked at 'called Result::unwrap() on an Err value: ffigen failed: stderr: Could not find package "ffigen". Did you forget to add a dependency? pub finished with exit code 65

stdout: ', /Users/wentao/.cargo/registry/src/github.com-1ecc6299db9ec823/flutter_rust_bridge_codegen-1.41.2/src/main.rs:24:43 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

I'll install a local 1.28.1 version for now until there is a walk around on this.

fzyzcjy commented 2 years ago

Hmm looks like a regression. @Roms1383 What do you think?

fzyzcjy commented 2 years ago

@wentao Btw could you please share the backtrace of the panic

wentao commented 2 years ago

Sure. Here is it

[2022-08-25T03:55:52Z WARN lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "cd /Users/wentao/Code/app && flutter pub run ffigen --config \"/var/folders/53/j6z_b9_s6tb79n5yr6p1fynr0000gn/T/.tmpxTNjBS\"" stdout= stderr=Could not find package "ffigen". Did you forget to add a dependency? pub finished with exit code 65

thread 'main' panicked at 'called Result::unwrap() on an Err value: ffigen failed: stderr: Could not find package "ffigen". Did you forget to add a dependency? pub finished with exit code 65

stdout: ', /Users/wentao/.cargo/registry/src/github.com-1ecc6299db9ec823/flutter_rust_bridge_codegen-1.41.2/src/main.rs:24:43 stack backtrace: 0: 0x10be2f2b7 - ::fmt::h85521558a183f368 1: 0x10bc50e7b - core::fmt::write::h01631fae0d2b98bc 2: 0x10be2b7bc - std::io::Write::write_fmt::h675dde99a2999169 3: 0x10be33b17 - std::panicking::default_hook::h18647b59f1a84ee2 4: 0x10be340f8 - std::panicking::rust_panic_with_hook::hd9ead35a68ccc55e 5: 0x10be34034 - std::panicking::begin_panic_handler::{{closure}}::h6fca91c5e1dc2f30 6: 0x10be32857 - std::sys_common::backtrace::rust_end_short_backtrace::h4ff3025d9a0a0490 7: 0x10be33d50 - _rust_begin_unwind 8: 0x10bf8c3f3 - core::panicking::panic_fmt::h3d9f795ee387ef8d 9: 0x10bf8c4e5 - core::result::unwrap_failed::haca1aa19e4c34aab 10: 0x10bc644e3 - flutter_rust_bridge_codegen::main::h759dd4ba2da1f5d5 11: 0x10bc62d06 - std::sys_common::backtrace::rust_begin_short_backtrace::h93db267c069f64c8 12: 0x10bc62cbc - std::rt::lang_start::{{closure}}::h68bb9d1e53382fa3 13: 0x10be273a1 - std::rt::lang_start_internal::h3fd5cff071397f19 14: 0x10bc647a9 - _main frb_codegen exited with non-zero

fzyzcjy commented 2 years ago

Well, not that useful indeed.

@Roms1383 Btw I guess we may need to refactor our error system - need to attach the stacktrace when error happens. For example, anyhow can auto do this.

Roms1383 commented 2 years ago

Sorry guys I missed github notification, so here is the additional argument. As far as I understand structopt docs, it probably have to be specified as --skip-deps-check. Is this how you tried it @wentao ?

fzyzcjy commented 2 years ago

@wentao RUST_LOG=debug flutter_rust_bridge_codegen --skip-deps-check --rust-input xplat/src/api.rs --dart-output lib/api_generated.dart -c ios/rust/ffi_bridge_generated.h

@Roms1383 seems yes, that flag

Roms1383 commented 2 years ago

Then it's clearly a bug... :man_facepalming: Ok I'll try to have a look in the coming days, sorry for the inconvenience.

fzyzcjy commented 2 years ago

@Roms1383 Take your time!

@wentao Also welcome to make a PR :)

Roms1383 commented 2 years ago

Well I quickly ran the command like : RUST_LOG=debug flutter_rust_bridge_codegen --skip-deps-check --rust-input ./native/src/api.rs --dart-output ./lib/bridge_generated.dart -c ./ios/Runner/bridge_generated.h and I couldn't reproduce locally.

See part of the logs here, you'll notice that skip_deps_check is indeed true:

click to expand

[2022-08-27T11:54:57Z INFO  lib_flutter_rust_bridge_codegen] Picked config: Opts { rust_input_path: "/Users/romain/Development/lab/cerclo-app/./native/src/api.rs", dart_output_path: "/Users/romain/Development/lab/cerclo-app/./lib/bridge_generated.dart", dart_decl_output_path: None, c_output_path: ["/Users/romain/Development/lab/cerclo-app/./ios/Runner/bridge_generated.h"], rust_crate_dir: "/Users/romain/Development/lab/cerclo-app/./native", rust_output_path: "/Users/romain/Development/lab/cerclo-app/./native/src/bridge_generated.rs", class_name: "Native", dart_format_line_length: 80, skip_add_mod_to_lib: false, llvm_path: ["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/Program Files/LLVM", "C:/msys64/mingw64"], llvm_compiler_opts: "", manifest_path: "/Users/romain/Development/lab/cerclo-app/./native/Cargo.toml", dart_root: Some("/Users/romain/Development/lab/cerclo-app"), build_runner: true, block_index: BlockIndex(0), skip_deps_check: true }

Here's my 2 cents on this since that's what happened to me last time : @wentao did you reinstall flutter_rust_bridge_codegen since its latest releases ?

You can do it by simply running: cargo install flutter_rust_bridge_codegen.

fzyzcjy commented 2 years ago

did you reinstall flutter_rust_bridge_codegen since its latest releases ?

And maybe use --version to see versions

franklyonnet commented 2 years ago

I just had the very same problem with version 1.41.3.

xxx@xxx yyy % export RUST_BACKTRACE=full
xxx@xxx yyy % flutter_rust_bridge_codegen --rust-input ./rust/userspace/src/api.rs --dart-output ./lib/bridge_generated.dart ...

thread 'main' panicked at 'called Result::unwrap() on an Err value: please add ffi to your dependencies. (version >=2.0.1, <3.0.0)', /Users/xxx/.cargo/registry/src/github.com-1ecc6299db9ec823/flutter_rust_bridge_codegen-1.41.3/src/main.rs:24:43 stack backtrace: 0: 0x109f07a27 - ::fmt::h33d4544161da9cd0 1: 0x109d2665b - core::fmt::write::h22b56d6d417c492d 2: 0x109f03dfc - std::io::Write::write_fmt::h515a8855c6a84843 3: 0x109f0c276 - std::panicking::default_hook::hc602c1312aa18d98 4: 0x109f0c868 - std::panicking::rust_panic_with_hook::h3147bfce63989ccb 5: 0x109f0c784 - std::panicking::begin_panic_handler::{{closure}}::h354f8ce5af2f2ce8 6: 0x109f0afc7 - std::sys_common::backtrace::rust_end_short_backtrace::h63e1494bcfb6c060 7: 0x109f0c4a0 - _rust_begin_unwind 8: 0x10a069c43 - core::panicking::panic_fmt::h6e7523bddca0f9b8 9: 0x10a069d35 - core::result::unwrap_failed::haf91c36a69e7d616 10: 0x109d3b493 - flutter_rust_bridge_codegen::main::h53cf7c3b68120bc3 11: 0x109d3a476 - std::sys_common::backtrace::rust_begin_short_backtrace::hff0fd5ecca170581 12: 0x109d3b9e1 - std::rt::lang_start::{{closure}}::heb753a8ce7a2080c 13: 0x109eff9ba - std::rt::lang_start_internal::h8e59f392f19ac690 14: 0x109d3b759 - _main

I had to downgrade to get a meaningful error message: cargo install --version 1.28.1 --force flutter_rust_bridge_codegen

flutter_rust_bridge_codegen --rust-input ./rust/userspace/src/api.rs --dart-output ./lib/bridge_generated.dart [2022-09-01T17:41:56Z WARN flutter_rust_bridge_codegen::commands] command="sh" "-c" "test -x \"$(which cbindgen)\"" stdout= stderr= [2022-09-01T17:41:56Z ERROR flutter_rust_bridge_codegen::commands] cbindgen is not a command, or not executable. Note: This command might be available via cargo, in which case it can be installed with:

    cargo install cbindgen

After cargo install cbindgen the older version of codegen works on my code.

But after installing back 1.41.3. > cargo install --force flutter_rust_bridge_codegen
I have the same error message. Even after a > cargo install --force cbindgen .

Roms1383 commented 2 years ago

https://user-images.githubusercontent.com/21016014/188058842-d74cbeaa-c4ce-461b-98c6-2b20ec36943a.mov

🤔

Roms1383 commented 2 years ago

You should add ffi and ffigen as suggested in the installing dependencies section of the book.

However, if you have e.g. a different repository setup and want to ignore dependencies check, you can disable it with CLI argument --skip-deps-check.

franklyonnet commented 2 years ago

Thanks a lot for taking the time @Roms1383. Yes indeed I missed that additional dependency during my project upgrade... This is working now with 1.41.3.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.