Closed CJBuchel closed 3 months ago
Hi! Thanks for opening your first issue here! :smile:
Firstly, what is your rust version? IIRC someone mentioned -> https://github.com/fzyzcjy/flutter_rust_bridge/issues/2157 too old rust may have problems
Secondly, it runs well on CI windows/macos/linux, thus maybe we can debug by checking what's different from CI.
Currently it's this
cargo 1.81.0-nightly (bc89bffa5 2024-06-22) rustup 1.27.1 (54dd3d00f 2024-04-24) rustc 1.81.0-nightly (fda509e81 2024-06-25)
I thought it might be a rust/flutter version issue, so I did an upgrade before hand. I think those are the latest versions
Hmm could you please google a bit about the error messages etc (e.g. a quick search gives https://github.com/fathyb/carbonyl/issues/133 but maybe different) - This looks like a general "why my Rust code does not compile" problem, since there is no frb or dart in this step, and it is only executing a pure cargo command:
"cargo" "build" "--lib" "--target" "wasm32-unknown-unknown" "-Z" "build-std=std,panic_abort"
Also try to execute that command directly on a terminal and see what happens
hmmmm.
so running the raw command works in the rust
crate in the my_app project. Now if I run the flutter_rust_bridge_codegen build-web
in the root project it works.
Just to check I deleted the target directory in the rust
crate and now when I run the flutter_rust_bridge_codegen build-web
I get the same set of weird errors again. So I guess I just have to compile the rust crate for wasm first before doing the codegen?
That's weird, I would guess it may be something related to env variable.
What about this: cargo build is auto run by the following command. When run it directly (after deleting target dir) does it work?
wasm-pack build -t no-modules -d /home/cj/Documents/code/flutter_ffi/my_app/web/pkg --no-typescript --out-name rust_lib_my_app --dev rust -- -Z build-std=std,panic_abort
Did a bit more testing.
with no target dir created flutter_rust_bridge_codegen build-web
fails like it did before.
when running cargo build
(without the wasm target in the command) the flutter_rust_bridge_codegen
works like normal.
And the raw command wasm-pack build -t no-modules -d /home/cj/Documents/code/flutter_ffi/my_app/web/pkg --no-typescript --out-name rust_lib_my_app --dev rust -- -Z build-std=std,panic_abort
also works fine.
cj@pop-os:~/Documents/code/flutter_ffi/my_app$ flutter_rust_bridge_codegen build-web
> which wasm-pack (pwd: null, env: null)
/home/cj/.cargo/bin/wasm-pack
> cargo read-manifest (pwd: rust, env: null)
> wasm-pack build -t no-modules -d /home/cj/Documents/code/flutter_ffi/my_app/web/pkg --no-typescript --out-name rust_lib_my_app --dev rust -- -Z build-std=std,panic_abort (pwd: null, env: {RUSTUP_TOOLCHAIN: nightly, RUSTFLAGS: -C target-feature=+atomics,+bulk-memory,+mutable-globals, CARGO_TERM_COLOR: always})
[INFO]: 🎯 Checking for the Wasm target...
[INFO]: 🌀 Compiling to Wasm...
I can also see the same command it's using when it launches the codegen. And it works fine by itself. So yea... I can only think my env variables are messed up for some reason. And it's not building the project properly when launched through the codegen.
I think so, probably because of some unknown env var issues... I do not have a reproducible environment, so cannot debug for this. If you like to test more, maybe clone frb repo and modify the ./frb_dart code related to building web to print out things etc to debug.
Yea, well it's good to know that it's an isolated issue at least. Easy enough to get around anyway in the short term. I'll close up the issue, and if I ever do find a long-term solution I'll chuck here in the future for anyone else who might stumble on it.
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.
Reopen because of https://github.com/fzyzcjy/flutter_rust_bridge/discussions/2236
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
I'm using the default project created from doing the
flutter_rust_bridge_codegen create my_app
, and I'm trying to get the web working in my environment.And following the docs I've installed the necessary toolchains, nightly build switch and the wasm-pack. But when I run the command for
build-web
I just get a heap of errors all relating to linking issues, making me think I don't have the correct libraries. But I'm pretty sure I've installed everything it's complaining about. (attached is the last one error, but they're all related to the same type of issue)Steps to reproduce
Hint: A simple way to reproduce is to clone and modify the https://github.com/fzyzcjy/flutter_rust_bridge/tree/master/frb_example/dart_minimal example package according to your needs.
flutter_rust_bridge_codegen create my_app
flutter_rust_bridge_codegen build-web
inmy_app
Logs
Expected behavior
Generates the output wasm files for flutter
Generated binding code
No response
OS
Pop OS 22 (linux)
Version of
flutter_rust_bridge_codegen
No response
Flutter info
Version of
clang++
No response
Additional context
No response