Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter_rust_bridge_codegen build-web fails due to no Flutter SDK #2480

Open
cameron1024 opened this issue Jan 4, 2025 · 8 comments
Open
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working

Comments

@cameron1024
Copy link

cameron1024 commented Jan 4, 2025

Describe the bug

I'm trying to add some Rust code to my Flutter Web application, and am unable to run the build-web command because of the error included below. I haven't modified the generated code at all, just trying to integrate then run.

Having a look at the code for the CLI, it looks like it's trying to invoke dart ... rather than flutter ..., so it's not able to resolve the flutter dependency from the SDK. This feels like a bug, but this is my first time using FRB, so I'm not sure if this user error on my part.

Unfortunately, the project is closed-source, so I can't share it here, but I was able to reproduce the same behavior from a fresh flutter web app created with flutter create foo

Steps to reproduce

  1. flutter create foo
  2. flutter_rust_bridge_codegen integrate
  3. flutter_rust_bridge_codegen build-web

Logs

❯ flutter_rust_bridge_codegen build-web
[2025-01-04T00:22:51.427Z WARN frb_codegen/src/library/commands/command_runner.rs:153] command="sh" "-c" "\"fvm\" \"--version\"" stdout= stderr=sh: line 1: fvm: command not found

[2025-01-04T00:22:51.427Z INFO frb_codegen/src/library/commands/fvm.rs:15] Has .fvmrc but no fvm binary installation, thus skip using fvm.
Resolving dependencies in `/home/cameron/projects/foo`...
Because foo depends on integration_test from sdk which doesn't exist (the Flutter SDK is not available), version
  solving failed.

Flutter users should use `flutter pub` instead of `dart pub`.

Error: Fail to execute command, please see logs above for details.

Stack backtrace:
   0: anyhow::error::<impl anyhow::Error>::msg
   1: lib_flutter_rust_bridge_codegen::library::build_web::build
   2: flutter_rust_bridge_codegen::main
   3: std::sys::backtrace::__rust_begin_short_backtrace
   4: std::rt::lang_start::{{closure}}
   5: std::rt::lang_start_internal
   6: main
   7: __libc_start_call_main
   8: __libc_start_main_alias_2
   9: _start

Expected behavior

It builds the web code

Generated binding code

No response

OS

Linux (NixOS)

Version of flutter_rust_bridge_codegen

2.7.0

Flutter info

❯ flutter doctor -v
[✓] Flutter (Channel stable, 3.24.4, on NixOS 25.05 (Warbler) 6.12.1, locale en_US.UTF-8)
    • Flutter version 3.24.4 on channel stable at
      /nix/store/rjz395nsk0zb67gaxkjc9qpx0khvl9d3-flutter-wrapped-3.24.4-sdk-links
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision nixpkgs000 (), 1970-01-01 00:00:00
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE =
      /nix/store/mik4wg86j6z7rj32ywzj5gpibz2j3dyw-google-chrome-131.0.6778.139/bin/google-chrome-stable

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

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • NixOS 25.05 (Warbler) 6.12.1
    • Chrome (web)    • chrome • web-javascript • Google Chrome 131.0.6778.139

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

! Doctor found issues in 2 categories.


### Version of `clang++`

_No response_

### Additional context

_No response_
@cameron1024 cameron1024 added the bug Something isn't working label Jan 4, 2025
Copy link

welcome bot commented Jan 4, 2025

Hi! Thanks for opening your first issue here! 😄

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jan 4, 2025

Hmm that's weird. We have CI to ensure such commands does work... Could you please share your created project (i.e. the folder you create in "steps to reproduce"), e.g. as a temporary github repo.

@cameron1024
Copy link
Author

Sure, I've pushed it here

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jan 4, 2025

Hmm try RUST_LOG=debug and run command again and paste the logs. Also do you run commands at exactly the repo folder?

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Jan 4, 2025
@cameron1024
Copy link
Author

Yep, I ran this to create that repo

flutter create frb_web_bug_demo
cd frb_web_bug_demo
flutter_rust_bridge_codegen integrate
flutter_rust_bridge_codegen build-web

Here's the logs with RUST_LOG=debug:

❯ RUST_LOG=debug flutter_rust_bridge_codegen build-web
[2025-01-05T00:06:06.849Z DEBUG frb_codegen/src/main.rs:25] cli=Cli { verbose: false, command: BuildWeb(BuildWebCommandArgs { dart_root: None, dart_coverage: false, args: [] }) }
[2025-01-05T00:06:06.850Z DEBUG frb_codegen/src/library/build_web/mod.rs:24] build dart_root="/home/cameron/projects/frb_web_bug_demo" args=[]
[2025-01-05T00:06:06.850Z DEBUG frb_codegen/src/library/utils/dart_repository/dart_repo.rs:21] Guessing toolchain the runner is run into
[2025-01-05T00:06:06.850Z DEBUG frb_codegen/src/library/commands/command_runner.rs:129] execute command: bin=sh args="-c \"fvm\" \"--version\"" current_dir=None cmd="sh" "-c" "\"fvm\" \"--version\""
[2025-01-05T00:06:06.853Z WARN frb_codegen/src/library/commands/command_runner.rs:153] command="sh" "-c" "\"fvm\" \"--version\"" stdout= stderr=sh: line 1: fvm: command not found

[2025-01-05T00:06:06.853Z INFO frb_codegen/src/library/commands/fvm.rs:15] Has .fvmrc but no fvm binary installation, thus skip using fvm.
Resolving dependencies in `/home/cameron/projects/frb_web_bug_demo`...
Because frb_web_bug_demo depends on integration_test from sdk which doesn't
  exist (the Flutter SDK is not available), version solving failed.

Flutter users should use `flutter pub` instead of `dart pub`.

Error: Fail to execute command, please see logs above for details.

Stack backtrace:
   0: anyhow::error::<impl anyhow::Error>::msg
   1: lib_flutter_rust_bridge_codegen::library::build_web::build
   2: flutter_rust_bridge_codegen::main
   3: std::sys::backtrace::__rust_begin_short_backtrace
   4: std::rt::lang_start::{{closure}}
   5: std::rt::lang_start_internal
   6: main
   7: __libc_start_call_main
   8: __libc_start_main_alias_2
   9: _start

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jan 5, 2025

Hmm it does not mention the toolchain or command used (but yes judging from command it may wrongly use dart). Maybe add another debug! near

debug!("Guessing toolchain the runner is run into");
and print the toolchain that it finally picks. (Also print manifest_file there may help)

@TheBotlyNoob
Copy link

A simple hack to work around the issue (albeit using a deprecated method) is by running:

flutter pub run flutter_rust_bridge build-web --dart-root <<flutter project dir>> <<flags for FRB (i.e. --verbose)>>

I don't know what repercussions there are to using the dart package directly instead of going through the rust wrapper, but it seems to work fine for now.

@TheBotlyNoob
Copy link

TheBotlyNoob commented Jan 6, 2025

For the record, a similar issue occurs when running dart run flutter_rust_bridge:serve. I'm not sure if that should be filed as a separate issue.

$ dart run flutter_rust_bridge:serve
Resolving dependencies in `/workspaces/flutter-proj`... 
Because flutter-proj depends on integration_test from sdk which doesn't exist (the Flutter SDK is not available), version
  solving failed.

Flutter users should use `flutter pub` instead of `dart pub`.

The workaround does not work with this command, however.

$ flutter pub run flutter_rust_bridge:serve
Deprecated. Use `dart run` instead.
Could not find bin/serve.dart in package flutter_rust_bridge.

EDIT: has flutter_rust_bridge_serve been removed? its still present in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants