当内置终端在 PATH 上找到 SDK 时,VS Code Flutter 扩展却找不到 SDK?

问题描述 投票:0回答:1

当我在 VS Code 内置终端中运行

flutter doctor
时,它报告一切正常,它找到了通过 VS Code 中的 Flutter 扩展安装在
/home/.../flutter
中的 flutter SDK。但是运行
Ctrl-Shift-P Flutter Doctor
报告Flutter SDK的路径不在PATH中:

OUTPUT
[flutter] flutter doctor -v
[!] Flutter (Channel stable, 3.27.3, on Ubuntu 24.04.1 LTS 6.8.0-51-generic, locale en_US.UTF-8)
    • Flutter version 3.27.3 on channel stable at /.../flutter
    ! The flutter binary is not on your path. Consider adding /.../bin to your path.
    ! The dart binary is not on your path. Consider adding /.../flutter/bin to your path.
    • Upstream repository https://github.com/flutter/flutter.git
...

扩展能否正常工作有问题吗?如何将其添加到路径中? IE。是在扩展设置中还是在全局 VS Code 设置中?我尝试添加“Dart SDK”和“Flutter SDK”的路径,但这没有帮助。

它是 Ubuntu 24.04。在安装扩展的过程中,我没有看到弹出窗口显示“您想将 Flutter SDK 添加到 PATH 以便可以在外部终端中访问它吗?”。

另外,我运行

fish
shell。 flutter SDK添加到
PATH
中的
.config/fish/config.fish
。内置终端运行
fish
,我认为这就是它选择正确的
PATH
的原因。我尝试在某处添加 SDK 路径 (
/home/.../flutter/bin/ and just 
/home/.../flutter/
) to the PATH in 
.bashrc
and
.bash_profile
, guessing that maybe VS Code tries to run 
bash`。但它也没有帮助。

linux flutter visual-studio-code
1个回答
0
投票

使用

setting.json
在 vscode 中打开
Ctrl-P
文件,然后分配 flutter sdk 路径

"dart.flutterSdkPath": path,
© www.soinside.com 2019 - 2024. All rights reserved.