繁体   English   中英

为什么我可以在 linux 终端中运行 flutter 命令,但不能在 vscode 终端中运行?

[英]Why i can run flutter command in linux terminal, but not in vscode terminal?

我使用 ZorinOS。 我安装了 flutter 并运行 flutter 博士,一切都很好。 我创建了新的 flutter 项目并从 vscode 中的命令托盘运行 flutter 医生,我得到:

[flutter] flutter doctor -v
[✓] Flutter (Channel stable, 3.3.2, on Freedesktop.org 21.08.15 (Flatpak runtime) 5.15.0-46-generic, locale en_US.UTF-8)
    • Flutter version 3.3.2 on channel stable at /home/lock_rr/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e3c29ec00c (27 hours ago), 2022-09-14 08:46:55 -0500
    • Engine revision a4ff2c53d8
    • Dart version 2.18.1
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /home/lock_rr/Android/Sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /home/lock_rr/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✗] 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
    • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    • cmake version 3.10.2
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.2)
    • Android Studio at /home/lock_rr/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Freedesktop.org 21.08.15 (Flatpak runtime) 5.15.0-46-generic

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
exit code 0

但是当我在我的 linux 终端中运行 flutter 医生时,我得到了不同的 output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.2, on Zorin OS 16.1 5.15.0-46-generic, locale
    en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

当我尝试在 vscode 终端中运行 flutter 时,我得到:

sh-5.1$ flutter run
sh: flutter: command not found

但我可以使用命令pallete 和linux 终端运行它。我尝试在我的vscode 终端中使用bash 但没有任何改变。 那么我该如何解决这个问题?

注意:我用铬填充我的 CHROME_EXECUTABLE 而不是铬。 但是当我在 linux 终端运行 flutter 医生时,它没有被检测为问题。

编辑:我尝试重新安装 flutter,但仍然无法访问它。 但是我在我的 vscode 终端中尝试which flutter并得到了:

sh-5.1$ which flutter
which: no flutter in (/app/bin:/app/bin:/app/bin:/usr/bin:/home/lock_rr/.var/app/com.visualstudio.code/data/node_modules/bin)

所以经过一些试验和错误。 我发现我的问题的根源是我的 vscode。 我从 linux 软件商店安装了 vscode,它没有工作。 我从 vscode 网站重新安装,它工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM