flutter_rust_bridge icon indicating copy to clipboard operation
flutter_rust_bridge copied to clipboard

[Bug] build_runner won't detect anything - because forget to add dependency libraries

Open lattice0 opened this issue 2 years ago • 2 comments

Describe the bug

My generated .dart file has

part 'dart_bridge_generated.freezed.dart';

and even though flutter_rust_bridge automatically runs build_runner, it detects nothing. build_runner is on my dependencies. Also, I tried manually:

flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 398ms

[WARNING] Invalidated precompiled build script due to core package update
[INFO] Precompiling build script......
[INFO] Precompiling build script... completed, took 8.6s

[SEVERE] Nothing can be built, yet a build was requested.
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 99ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 673ms

[INFO] Running build...
[INFO] Running build completed, took 6ms

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 48ms

[INFO] Succeeded after 72ms with 0 outputs (0 actions)

Codegen logs with RUST_LOG=debug environment variable

[2022-06-30T21:00:26Z INFO  lib_flutter_rust_bridge_codegen::commands] Running build_runner at /home/dev/project/liblibsomething/../flutter_libsomething_app
[2022-06-30T21:00:26Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute command: bin=sh args=["-c", "cd \"/home/dev/project/liblibsomething/../flutter_libsomething_app\" && dart run build_runner build --delete-conflicting-outputs"] current_dir=None cmd="sh" "-c" "cd \"/home/dev/project/liblibsomething/../flutter_libsomething_app\" && dart run build_runner build --delete-conflicting-outputs"
[2022-06-30T21:00:54Z DEBUG lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "cd \"/home/dev/project/liblibsomething/../flutter_libsomething_app\" && dart run build_runner build --delete-conflicting-outputs" stdout=[INFO] Generating build script...
    [INFO] Generating build script completed, took 341ms
    
    [WARNING] Invalidated precompiled build script due to core package update
    [INFO] Precompiling build script......
    [INFO] Precompiling build script... completed, took 7.5s
    
    [SEVERE] Nothing can be built, yet a build was requested.
    [INFO] Initializing inputs
    [INFO] Reading cached asset graph...
    [INFO] Reading cached asset graph completed, took 61ms
    
    [INFO] Checking for updates since last build...
    [INFO] Checking for updates since last build completed, took 689ms
    
    [INFO] Running build...
    [INFO] Running build completed, took 2ms
    
    [INFO] Caching finalized dependency graph...
    [INFO] Caching finalized dependency graph completed, took 34ms
    
    [INFO] Succeeded after 49ms with 0 outputs (0 actions)
    
     stderr=
[2022-06-30T21:00:54Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute format_dart path=/home/dev/project/liblibsomething/../flutter_libsomething_app/lib/dart_bridge_generated.freezed.dart line_length=80
[2022-06-30T21:00:54Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute command: bin=sh args=["-c", "dart format /home/dev/project/liblibsomething/../flutter_libsomething_app/lib/dart_bridge_generated.freezed.dart --line-length 80"] current_dir=None cmd="sh" "-c" "dart format /home/dev/project/liblibsomething/../flutter_libsomething_app/lib/dart_bridge_generated.freezed.dart --line-length 80"
[2022-06-30T21:00:54Z DEBUG lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "dart format /home/dev/project/liblibsomething/../flutter_libsomething_app/lib/dart_bridge_generated.freezed.dart --line-length 80" stdout=Formatted no files in 0.01 seconds.
     stderr=No file or directory found at "/home/dev/project/liblibsomething/../flutter_libsomething_app/lib/dart_bridge_generated.freezed.dart".
    
[2022-06-30T21:00:54Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute format_dart path=/home/dev/project/liblibsomething/../flutter_libsomething_app/lib/dart_bridge_generated.dart line_length=80
[2022-06-30T21:00:54Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute command: bin=sh args=["-c", "dart format /home/dev/project/liblibsomething/../flutter_libsomething_app/lib/dart_bridge_generated.dart --line-length 80"] current_dir=None cmd="sh" "-c" "dart format /home/dev/project/liblibsomething/../flutter_libsomething_app/lib/dart_bridge_generated.dart --line-length 80"
[2022-06-30T21:00:55Z DEBUG lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "dart format /home/dev/project/liblibsomething/../flutter_libsomething_app/lib/dart_bridge_generated.dart --line-length 80" stdout=Formatted /home/dev/project/liblibsomething/../flutter_libsomething_app/lib/dart_bridge_generated.dart
    Formatted 1 file (1 changed) in 0.35 seconds.
     stderr=
[2022-06-30T21:00:55Z INFO  lib_flutter_rust_bridge_codegen] Success!
[2022-06-30T21:00:55Z INFO  flutter_rust_bridge_codegen] Now go and use it :)

To Reproduce

No response

Expected behavior

No response

Generated binding code

No response

OS

No response

Version of flutter_rust_bridge_codegen

No response

Flutter info

No response

Version of clang++

No response

Version of ffigen

No response

Additional context

No response

lattice0 avatar Jun 30 '22 21:06 lattice0

Solution: flutter pub add --dev freezed

but also make sure of the following:

flutter pub add freezed_annotation
flutter pub add --dev build_runner

lattice0 avatar Jun 30 '22 21:06 lattice0

Solution

Yes you need to do that.

Feel free to PR :) For example, when flutter_rust_bridge_codegen runs and wants to output a freezed dart class, it should check pubspec.yaml, and ensure there are freezed, freezed_annotation, build_runner there on dependencies/dev_dependencies sections.

fzyzcjy avatar Jun 30 '22 22:06 fzyzcjy

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.

stale[bot] avatar Aug 31 '22 00:08 stale[bot]

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.

github-actions[bot] avatar Sep 21 '22 01:09 github-actions[bot]