Closed wentao closed 1 year 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
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?
As far as I understand it (waiting for @wentao for more context), there's a couple of ways to address this :
pubspec.yaml
/ pubspec. lock
but this could be error-prone if ever people have very exotic project files hierarchyWhat do you think @fzyzcjy?
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
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:
'/var/folders/53/j6z_b9_s6tb79n5yr6p1fynr0000gn/T/.tmpolxQYj.h' comments: false preamble: | // ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names
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_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`
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.
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
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
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?
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.
Does cli require ffigen an executable command? How do I install one so the cli won't fail?
Yes it requires
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.
Hmm looks like a regression. @Roms1383 What do you think?
@wentao Btw could you please share the backtrace of the panic
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 -
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.
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 ?
@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
Then it's clearly a bug... :man_facepalming: Ok I'll try to have a look in the coming days, sorry for the inconvenience.
@Roms1383 Take your time!
@wentao Also welcome to make a PR :)
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
.
did you reinstall flutter_rust_bridge_codegen since its latest releases ?
And maybe use --version
to see versions
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 -
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 .
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
.
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.
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.
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.
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 anErr
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:43Codegen logs with
RUST_LOG=debug
environment variableTo 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
Version of
clang++
No response
Version of
ffigen
No response
Additional context
No response