Reputation: 137
Vscode can't locate the flutter sdk.
I read the error log and it says that the dart extension returned undefined for the sdk location path because it looked through the PATH and didn't find it there, even though I can run flutter command from VScode terminal window no problem.
I tried to make another copy of flutter sdk dir and placed it in /usr/local/bin and updated my PATH again, still I can run flutter from terminal but VScode dart extension won't find it for some reason.
my current environment state.
vscode version : 1.36.1 dart version : 2.4.0 flutter version : 1.7.8+hotfix.3
my log
Sat Jul 20 2019 [06:43:47 GMT+0300 (Arabian 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
Upvotes: 3
Views: 6009
Reputation: 11
.vscode/settings.json - there may be a wrong sdk path there try to change it
Upvotes: 0
Reputation: 239
Quick fix for mac users close visual studio code completely... don't restart it from the dock. find VS Code with cmd spacebar.
VS code will be now be able to locate flutter SDK in path.
Upvotes: 0
Reputation: 42433
The VS Code extension searchs the PATH
environment variable for Dart/Flutter since most people have it on PATH
. However, sometimes PATH
is set in a way that VS Code does not see it (for example if you set it in a terminal startup script, but launch VS Code from the dock, it might not inherit that PATH
).
The simplest thing to do is when you get the error message, click the Locate SDK button and select the folder manually. This will store the folder in your VS Code settings and it will be included in the search path next time around.
Upvotes: 2