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.08k stars 277 forks source link

'flutter_rust_bridge_codegen --template plugin' fails with error: path not found #2208

Closed Markus43 closed 1 month ago

Markus43 commented 1 month ago

Describe the bug

I try to run flutter_rust_bridge_codegen --template plugin, but it does not work for me: It stops with an error, and the plugin project looks incomplete. The error message "Das System kann den angegebenen Pfad nicht finden." translates to something like "The system can not find the path specified".

Steps to reproduce

c:\test>flutter --version Flutter 3.22.2 • channel stable • https://github.com/flutter/flutter.git Framework • revision 761747bfc5 (6 weeks ago) • 2024-06-05 22:15:13 +0200 Engine • revision edd8546116 Tools • Dart 3.4.3 • DevTools 2.34.3

c:\test>rustc --version rustc 1.79.0 (129f3b996 2024-06-10)

c:\test>flutter_rust_bridge_codegen --version flutter_rust_bridge_codegen 2.1.0

c:\test>flutter_rust_bridge_codegen -v create mytestplugin --template plugin

Logs

[2024-07-17T11:49:00.937Z DEBUG C:\Users\Markus\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.1.0\src/main.rs:24] cli=Cli { verbose: true, command: Create(CreateCommandArgs { name: "mytestplugin", org: None, common: CreateOrIntegrateCommandCommonArgs { rust_crate_name: None, rust_crate_dir: None, local: false }, template: Plugin }) }
[2024-07-17T11:49:00.937Z DEBUG C:\Users\Markus\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.1.0\src\library\integration\creator.rs:22] create name=mytestplugin org=None dart_root="c:\\test\\mytestplugin"
[2024-07-17T11:49:00.938Z INFO C:\Users\Markus\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.1.0\src\library\commands\flutter.rs:23] Execute `flutter create mytestplugin --template plugin_ffi --platforms android,ios,linux,macos,windows` (this may take a while)
[2024-07-17T11:49:00.938Z DEBUG C:\Users\Markus\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.1.0\src\library\commands\command_runner.rs:129] execute command: bin=powershell args="-noprofile -command & \"flutter\" \"create\" \"mytestplugin\" \"--template\" \"plugin_ffi\" \"--platforms\" \"android,ios,linux,macos,windows\"" current_dir=None cmd="powershell" "-noprofile" "-command" "& \"flutter\" \"create\" \"mytestplugin\" \"--template\" \"plugin_ffi\" \"--platforms\" \"android,ios,linux,macos,windows\""
[2024-07-17T11:49:05.295Z DEBUG C:\Users\Markus\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.1.0\src\library\commands\command_runner.rs:140] command="powershell" "-noprofile" "-command" "& \"flutter\" \"create\" \"mytestplugin\" \"--template\" \"plugin_ffi\" \"--platforms\" \"android,ios,linux,macos,windows\"" stdout=Creating project mytestplugin...
Resolving dependencies in `mytestplugin`...
Downloading packages...
Got dependencies in `mytestplugin`.
Resolving dependencies in `mytestplugin\example`...
Downloading packages...
Got dependencies in `mytestplugin\example`.
Wrote 77 files.

All done!

Your plugin code is in mytestplugin\lib\mytestplugin.dart.

Your example app code is in mytestplugin\example\lib\main.dart.

Host platform code is in the android, ios, linux, macos, windows directories under mytestplugin.
To edit platform code in an IDE see https://flutter.dev/developing-packages/#edit-plugin-package.

The desktop platform: macos is currently not supported on your local environment.
For more details, see: https://flutter.dev/desktop

To add platforms, run `flutter create -t plugin_ffi --platforms <platforms> .` under mytestplugin.
For more information, see https://flutter.dev/go/plugin-platforms.

 stderr=
Error: Das System kann den angegebenen Pfad nicht finden. (os error 3)

Expected behavior

No response

Generated binding code

No response

OS

Windows

Version of flutter_rust_bridge_codegen

2.1.0

Flutter info

No response

Version of clang++

No response

Additional context

No response

fzyzcjy commented 1 month ago

Hmm, could you please try RUST_LOG=debug env var, as well as full backtrace, and run it again and paste the logs here? Then it may be easier to see what is going on

Markus43 commented 1 month ago

I did set RUST_LOG=debug, and I believe that the stdout= and stderr= values come from the logged command in the 5th line, don't they?

How do I get a full backtrace here? The tool just seems to cancel because it got a failure from the flutter tool, didn't it?

I also tried this command (which is being called according to the logs): flutter create mytestplugin --template plugin_ffi --platforms android,ios,linux,macos,windows when I directly call this, I don't get a stderr as in the logs. Maybe that specific flutter call is somehow broken in windows?

fzyzcjy commented 1 month ago

Oh yes, I overlooked it.

Maybe that specific flutter call is somehow broken in windows?

Yes I think so... It may be possible related to how it is executed. Could you please try to execute the command including the prefix mentioned in the logs - powershell -noprofile -command & flutter create ... and see whether it runs?

Btw, if you have WSL (which many programmers using windows to develop has), it may also be run there.

Yet another workaround is to clone https://github.com/fzyzcjy/flutter_rust_bridge/tree/master/frb_example/flutter_package and modify slightly (e.g. change dependency to the released frb version) and use it.

I personally do not use windows, and the windows on GitHub CI works well, thus I may not be able to directly point out what is going wrong... only to guess maybe it is some windows execution problems (like you guessed).

Markus43 commented 1 month ago

The PR fixes the runtime error. It wasn't the powershell command, it was the cleanup commands after that powershell command - as visible by the newline after stderr= in the logs ;-)

fzyzcjy commented 1 month ago

Great job!

github-actions[bot] commented 3 weeks 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.