localizely / flutter-intl-vscode

This VS Code extension generates boilerplate code for localization of Flutter apps with official Dart Intl library
MIT License
88 stars 1 forks source link

'Flutter SDK not available' when trying to run 'Flutter Intl: Initialize' #107

Open NikolozMiruashvili opened 1 year ago

NikolozMiruashvili commented 1 year ago

I am able to use all the VsCode and terminal functions normally but when trying to run 'Flutter Intl: Initialize' .

Here is output of flutter doctor -v:

[✓] Flutter (Channel stable, 3.10.1, on Ubuntu 23.04 6.4.0-060400rc1-generic, locale en_US.UTF-8) • Flutter version 3.10.1 on channel stable at /home/nikolozm/snap/flutter/common/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision d3d8effc68 (4 days ago), 2023-05-16 17:59:05 -0700 • Engine revision b4fb11214d • Dart version 3.0.1 • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) • Android SDK at /home/nikolozm/Android/Sdk • Platform android-33-ext4, build-tools 33.0.1 • Java binary at: /snap/android-studio/125/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted.

[✓] Chrome - develop for the web • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop • clang version 10.0.0-4ubuntu1 • cmake version 3.16.3 • ninja version 1.10.0 • pkg-config version 0.29.1

[✓] Android Studio (version 2021.3) • Android Studio at /snap/android-studio/125/android-studio • Flutter plugin version 71.2.3 • Dart plugin version 213.7433 • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.78.2) • VS Code at /usr/share/code • Flutter extension version 3.64.0

[✓] Connected device (3 available) • SM G935F (mobile) • ce041604b48bea1f03 • android-arm64 • Android 8.0.0 (API 26) • Linux (desktop) • linux • linux-x64 • Ubuntu 23.04 6.4.0-060400rc1-generic • Chrome (web) • chrome • web-javascript • Google Chrome 113.0.5672.126

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

• No issues found!

lzoran commented 1 year ago

Tried to reproduce this issue on Windows with VS Code 1.78.2 and Flutter Intl 1.19.2, and it seems that everything works fine.

Could you check if reactivating the intl_utils package helps (this might solve some cache issue)?

  1. Deactivate package with flutter pub global deactivate intl_utils
  2. Run 'Flutter Intl: Initialize' command.

If reactivation of the intl_utils does not help, could you provide us a minimal reproducible sample, VS Code version, Flutter Intl version, so we can easier detect what is the issue.

NikolozMiruashvili commented 1 year ago

Tried to reproduce this issue on Windows with VS Code 1.78.2 and Flutter Intl 1.19.2, and it seems that everything works fine.

Could you check if reactivating the intl_utils package helps (this might solve some cache issue)?

1. Deactivate package with `flutter pub global deactivate intl_utils`

2. Run 'Flutter Intl: Initialize' command.

If reactivation of the intl_utils does not help, could you provide us a minimal reproducible sample, VS Code version, Flutter Intl version, so we can easier detect what is the issue.

running flutter pub global deactivate intl_utils gave result 'No active package intl_utils.' and 'Flutter Intl: Initialize' gave same result as before. I have intl version: v1.19.2 and vs code version: 1.78.2. The issue does not seem dependent on the project at all. It persists even when I try to activate it for the default template of flutter application.

leogaggl commented 1 year ago

I can confirm the same issue using Flutter 3.10.3 with VSCode 1.78.2 and the Flutter Intl 1.19.2 plugin on OS: Ubuntu 22.04 LTS

General info

image

Packages: intl 0.18.0 intl_utils 2.8.3

flutter sdk-path /home/user/snap/flutter/common/flutter

leogaggl commented 1 year ago

Minimal way to reproduce:

Create a new Flutter project in Visual Studio

flutter create testapp
cd testapp
flutter pub add flutter_localizations --sdk=flutter
flutter pub add intl:any

CTRL+SHIFT+P --> Flutter Intl: Initialize

Flutter install, builds, and everything else works fine. Path variables areOK. All other Flutter commands are in the VSCode Command Palette.

lzoran commented 1 year ago

I believe I've identified the source of the problem.

The issue seems to be related to the Flutter installation through snapd.

To fix this, I updated the system path:

  1. Open the file named .bashrc located in your home directory ($HOME/.bashrc).
  2. Append the following line: export PATH="$PATH:[PATH_OF_FLUTTER_GIT_DIRECTORY]/bin"
  3. Restart VS Code and try to run Flutter Intl: Initialize

Could you please try these steps to see if it resolves your issue?

leogaggl commented 1 year ago

Thanks for the quick reply @lzoran

I can indeed confirm that adding:

"$HOME/snap/flutter/common/flutter/bin"

To the system path and restarting VSCode has fixed this problem. It's kind of strange that this only affects this plugin and everything else works.

Cheers from down under!

lzoran commented 1 year ago

I'm glad to hear that the posted solution was of help!

To the system path and restarting VSCode has fixed this problem. It's kind of strange that this only affects this plugin and everything else works.

You're right. I can't recall exactly, but it's likely that the installation documentation was updated at some point, and that I've missed to test the Flutter Intl extension when Flutter was installed using snapd.

I would like to examine if there's a way to solve this issue without system path modifications. So, I suggest keeping this issue open.

leogaggl commented 1 year ago

I would like to examine if there's a way to solve this issue without system path modifications. So, I suggest keeping this issue open.

That sounds good. Thanks for your help again!

If you need me to test anything feel free to ping me.

Elf80lvl commented 1 year ago

for me adding path to .bashrc did not do the trick. What I did to solve the issue: 1) In VS Code go to File-Preferences-Settings. 2) Type "flutter SDK" in search. 3) Under "Dart: Flutter SDK Path" click "Edit in settings.json" 4) Add path to dart.flutterSdkPath like this: "dart.flutterSdkPath": "/home/YourUserNameHere/snap/flutter/common/flutter/bin"

areynoso13 commented 2 months ago

For anyone wondering, I solved this problem with two approach:

  1. Add flutter to the global PATH, this solved the issue with Flutter Intl: Initialize

  2. if you want to generate the locales manually: Add intl_utils to the pubspec.yaml and run on the terminal: flutter pub run intl_utils:generate

NOTE: I tested on MacOs, Windows and Ubuntu, and it only happens on ubuntu