VScode unable to locate flutter sdk dir

2,563

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.

Share:
2,563
RootOfMinusOne
Author by

RootOfMinusOne

Updated on December 12, 2022

Comments

  • RootOfMinusOne
    RootOfMinusOne over 1 year

    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.

    • dart installed from brew
    • flutter sdk located in ~/Downloads
    • added flutter sdk to my PATH variable
    • flutter plugin installed in VScode
    • dart plugin installed in VScode
    • flutter doctor returns no errors

    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
    
    • Saeiddjawadi
      Saeiddjawadi almost 5 years
      could you please send log from flutter doctor?