cunarist / rinf

Rust for native business logic, Flutter for flexible and beautiful GUI
MIT License
1.88k stars 65 forks source link

Every rinf command errors - Flutter users should use `flutter pub` instead of `dart pub`. #336

Closed brongan closed 1 month ago

brongan commented 3 months ago

Report

Every rinf command I run gives the error message:


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

Steps to Reproduce

I truly do not know what I did to my flutter installation to get to this point. I know that I see this error message when I attempt to use the dart cli instead of the flutter cli to install dependencies.

System Information

Please provide the output from the command below, using markdown codeblock syntax.

rustc 1.80.0-nightly (faefc618c 2024-05-07)
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel , 3.22.0, on Arch Linux 6.9.1-zen1-2-zen, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    ✗ Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] Connected device (1 available)
[✓] Network resources

! Doctor found issues in 3 categories.
temeddix commented 3 months ago

Hi brongan, thanks for coming back :)

Our user installation CI is checking whether there's a problem for users during installation and app development. Below is a link to one of the latest workflows:

Here, that error messages doesn't seem to appear, nor on my local machine. Would you try running flutter clean and tell me if the problem remains?

brongan commented 3 months ago

Hey :)

flutter clean does not resolve the issue.

flutter create test
cd test
flutter pub add rinf
rinf message

results in the same error for me. It's most likely an issue with my flutter toolchain installation.

brongan commented 3 months ago

Could you change from running dart run rinf to flutter pub run rinf? I could send a pull request if that helps.

temeddix commented 3 months ago

Thank you for the investigation. flutter pub run rinf does work, but it show the output like below on my machine:

flutter pub run rinf
Deprecated. Use `dart run` instead.
Building package executable... 
Built rinf:rinf.
No operation is provided.
Use `rinf --help` to see all available operations.

I remember that flutter pub run was claiming to be 'deprecated', and that's why Rinf was using dart pub run.

FYI, I'm using the latest version of SDKs just like you.

rustc 1.78.0 (9b00956e5 2024-04-29)

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.22.1, on Microsoft Windows [Version 10.0.22631.3593], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[X] Android toolchain - develop for Android devices
    X 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/docs/get-started/install/windows#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
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6)
[!] Android Studio (not installed)
[√] VS Code (version 1.89.1)
[√] Connected device (3 available)
[√] Network resources

What would be the reason for this difference? If we reach the conclusion, I will be happy to make a new version of Rinf very soon.

asaphaaning commented 2 months ago

Experiencing the same exact problem as OP.

❯ flutter pub add rinf
Resolving dependencies...
Downloading packages...
  collection 1.18.0 (1.19.0 available)
+ ffi 2.1.2
  flutter_lints 3.0.2 (4.0.0 available)
  leak_tracker 10.0.4 (10.0.5 available)
  leak_tracker_flutter_testing 3.0.3 (3.0.5 available)
  lints 3.0.0 (4.0.0 available)
  material_color_utilities 0.8.0 (0.12.0 available)
  meta 1.12.0 (1.15.0 available)
+ package_config 2.1.0
+ rinf 6.12.1
  test_api 0.7.0 (0.7.2 available)
  vm_service 14.2.1 (14.2.4 available)
+ watcher 1.1.0
+ yaml 3.1.2
Changed 5 dependencies!
9 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

/tmp/test 5s
❯ rinf template
Detected `protoc`, skipping auto installation.
Resolving dependencies in `/tmp/test`...
Because test depends on flutter_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`.

/tmp/test
❯ flutter clean
Deleting .dart_tool...                                               0ms
Deleting Generated.xcconfig...                                       0ms
Deleting flutter_export_environment.sh...                            0ms
Deleting ephemeral...                                                0ms
Deleting ephemeral...                                                0ms
Deleting ephemeral...                                                0ms
Deleting .flutter-plugins-dependencies...                            0ms
Deleting .flutter-plugins...                                         0ms

/tmp/test
❯ flutter pub get
Resolving dependencies...
Downloading packages...
  collection 1.18.0 (1.19.0 available)
  flutter_lints 3.0.2 (4.0.0 available)
  leak_tracker 10.0.4 (10.0.5 available)
  leak_tracker_flutter_testing 3.0.3 (3.0.5 available)
  lints 3.0.0 (4.0.0 available)
  material_color_utilities 0.8.0 (0.12.0 available)
  meta 1.12.0 (1.15.0 available)
  test_api 0.7.0 (0.7.2 available)
  vm_service 14.2.1 (14.2.4 available)
Got dependencies!
9 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

/tmp/test
❯ rinf template
Detected `protoc`, skipping auto installation.
Resolving dependencies in `/tmp/test`...
Because test depends on flutter_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`.
asaphaaning commented 2 months ago

Additionally, the following also fails:

❯ flutter pub run rinf template
Deprecated. Use `dart run` instead.
Resolving dependencies...
Downloading packages...
Got dependencies.
Resolving dependencies...
Downloading packages...
Got dependencies.
Building package executable...
Built rinf:rinf.
protoc-gen-dart: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--dart_out: protoc-gen-dart: Plugin failed with status code 1.
Unhandled exception:
Exception: Could not compile `.proto` files into Dart
#0      generateMessageCode (file:///home/haaning/.pub-cache/hosted/pub.dev/rinf-6.12.1/bin/src/message.dart:205:7)
<asynchronous suspension>
#1      applyRustTemplate (file:///home/haaning/.pub-cache/hosted/pub.dev/rinf-6.12.1/bin/src/helpers.dart:175:3)
<asynchronous suspension>
#2      main (file:///home/haaning/.pub-cache/hosted/pub.dev/rinf-6.12.1/bin/rinf.dart:19:7)
<asynchronous suspension>
brongan commented 2 months ago

protoc-gen-dart: program not found or is not executable Please specify a program using absolute path or make sure the program is available in your PATH system variable

Have you considered adding protoc-gen-dart to your $PATH

asaphaaning commented 2 months ago

protoc-gen-dart: program not found or is not executable Please specify a program using absolute path or make sure the program is available in your PATH system variable

Have you considered adding protoc-gen-dart to your $PATH

It's in the path but somehow not picked up. After manually specifying it as well as the Dart protoc_plugin package, the template finally builds:

❯ PATH=$PATH:/home/haaning/.cargo/bin:/home/haaning/.pub-cache/bin flutter pub run rinf template
Deprecated. Use `dart run` instead.
Resolving dependencies... 
Downloading packages... 
Got dependencies.
Resolving dependencies... 
Downloading packages... 
Got dependencies.
Building package executable... 
Built rinf:rinf.
🎉 Rust template is now ready! 🎉

Note: No need for condescension, we're all here to share and learn.

AdjectiveAllison commented 2 months ago

Hi, I had the same issue. It ended up being that my FLUTTER_ROOT environment variable was not defined anywhere, and rinf template uses that variable to know where to look for the flutter sdk. I'm on arch linux and installed flutter via the AUR. I was able to use readlink to find where my sdk was installed, see here:

readlink -f $(which flutter)
/usr/lib/flutter/bin/flutter

I then ran rinf template with FLUTTER_ROOT set and it worked!

FLUTTER_ROOT=/usr/lib/flutter rinf template
Building package executable...
Built rinf:rinf.
🎉 Rust template is now ready! 🎉

vs, with it not set, you can see it doesn't:

 rinf template
Resolving dependencies in `/brrr/git/stupid`...
Because stupid depends on flutter_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`.

I have since manually added FLUTTER_ROOT to my shell variables in order to run rinf happily without specifying in-line now.