VScode 无法找到颤振 sdk 目录
Posted
技术标签:
【中文标题】VScode 无法找到颤振 sdk 目录【英文标题】:VScode unable to locate flutter sdk dir 【发布时间】:2019-11-28 23:46:02 【问题描述】:Vscode 找不到flutter sdk。
我阅读了错误日志,上面写着 dart 扩展为 sdk 位置路径返回未定义,因为它查看了 PATH 并没有找到它,即使我可以从 VScode 终端窗口运行颤振命令也没问题。
我尝试制作另一个flutter sdk dir的副本并将其放置在/usr/local/bin中并再次更新了我的PATH,我仍然可以从终端运行flutter,但VScode dart扩展由于某种原因找不到它。
我当前的环境状态。
从 brew 安装飞镖 flutter sdk 位于 ~/Downloads 将 Flutter sdk 添加到我的 PATH 变量中 在 VScode 中安装了 Flutter 插件 在 VScode 中安装了 dart 插件 flutter doctor 没有返回错误vscode 版本:1.36.1 飞镖版本:2.4.0 颤振版本:1.7.8+hotfix.3
我的日志
Sat Jul 20 2019 [06:43:47 GMT+0300 (Ar*** Standard Time)] Log file started
[6:43:47 AM] [General] [Info] Searching for SDKs...
[6:43:47 AM] [General] [Info] Environment PATH:
[6:43:47 AM] [General] [Info] /usr/local/bin
[6:43:47 AM] [General] [Info] /usr/bin
[6:43:47 AM] [General] [Info] /bin
[6:43:47 AM] [General] [Info] /usr/sbin
[6:43:47 AM] [General] [Info] /sbin
[6:43:47 AM] [General] [Info] Searching for flutter
[6:43:47 AM] [General] [Info] Looking for flutter in:
[6:43:47 AM] [General] [Info] /usr/local/bin
[6:43:47 AM] [General] [Info] /usr/bin
[6:43:47 AM] [General] [Info] /bin
[6:43:47 AM] [General] [Info] /usr/sbin
[6:43:47 AM] [General] [Info] /sbin
[6:43:47 AM] [General] [Info] Found at:
[6:43:47 AM] [General] [Info] /usr/local/bin
[6:43:47 AM] [General] [Info] Candidate paths to be post-filtered:
[6:43:47 AM] [General] [Info] /usr/local
[6:43:47 AM] [General] [Info] Returning SDK path undefined for flutter
[6:43:47 AM] [General] [Info] Searching for dart
[6:43:47 AM] [General] [Info] Looking for dart in:
[6:43:47 AM] [General] [Info] /usr/local/bin
[6:43:47 AM] [General] [Info] /usr/bin
[6:43:47 AM] [General] [Info] /bin
[6:43:47 AM] [General] [Info] /usr/sbin
[6:43:47 AM] [General] [Info] /sbin
[6:43:47 AM] [General] [Info] Found at:
[6:43:47 AM] [General] [Info] /usr/local/bin
[6:43:47 AM] [General] [Info] Following symlink: /usr/local/bin/dart ==> /usr/local/Cellar/dart/2.4.0/libexec/bin/dart
[6:43:47 AM] [General] [Info] Candidate paths to be post-filtered:
[6:43:47 AM] [General] [Info] /usr/local/Cellar/dart/2.4.0/libexec
[6:43:47 AM] [General] [Info] Found at /usr/local/Cellar/dart/2.4.0/libexec
[6:43:47 AM] [General] [Info] Returning SDK path /usr/local/Cellar/dart/2.4.0/libexec for dart
【问题讨论】:
能否请您发送颤振医生的日志? 【参考方案1】:VS Code 扩展在 PATH
环境变量中搜索 Dart/Flutter,因为大多数人在 PATH
上都有它。但是,有时PATH
以 VS Code 看不到的方式设置(例如,如果您在终端启动脚本中设置它,但从 Dock 启动 VS Code,它可能不会继承 PATH
)。
最简单的做法是当您收到错误消息时,单击Locate SDK 按钮并手动选择文件夹。这会将文件夹存储在您的 VS Code 设置中,并且下次它会包含在搜索路径中。
【讨论】:
【参考方案2】:Mac 用户快速修复 完全关闭 Visual Studio 代码...不要从扩展坞重新启动它。使用 cmd 空格键查找 VS Code。
VS 代码现在可以在路径中定位 Flutter SDK。
【讨论】:
以上是关于VScode 无法找到颤振 sdk 目录的主要内容,如果未能解决你的问题,请参考以下文章
命令“颤振:新项目”导致错误(找不到命令“颤振.createProject”),我无法在 VSCODE 上调试颤振项目