Dart-Code / Dart-Code

Dart and Flutter support for VS Code
https://dartcode.org/
MIT License
1.49k stars 303 forks source link

Dart sdk path not found if there is a folder named "flutter" in project root directory #1470

Closed voiddog closed 5 years ago

voiddog commented 5 years ago

My vscode flutter plugin version is: 2.23.0

How to reproduce this problem: Create a new flutter plugin project and create a directory called flutter in the project root directory

At this point, opening this project with vscode will appear dart sdk not found.

DanTup commented 5 years ago

Can you clarify the exact wording of the message you receive of provide a screenshot? There are a few similar messages and I'm not sure which one you're seeing.

There is also a "Show Logs" button on some of those errors, if there is one here, please attach the log.

Thanks!

voiddog commented 5 years ago

Demo project: https://github.com/voiddog/flutter_issues_demo

Use the vscode to open the project above, will get log below:

Here is the log: Tue Feb 19 2019 [15:58:50 GMT+0800 (CST)] Log file started [15:58:50 GMT+0800 (CST)] [General] [Info] Searching for SDKs... [15:58:50 GMT+0800 (CST)] [General] [Info] Environment PATH: [15:58:50 GMT+0800 (CST)] [General] [Info] /Applications/MacVim.app/Contents/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Library/Android/sdk/platform-tools [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Library/Python/2.7/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/flutter/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/local/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/local/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/sbin [15:58:50 GMT+0800 (CST)] [General] [Info] /sbin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/depot_tools [15:58:50 GMT+0800 (CST)] [General] [Info] Found Flutter project at /Users/qigengxin/Documents/Github/flutter_issues [15:58:50 GMT+0800 (CST)] [General] [Info] Searching for flutter [15:58:50 GMT+0800 (CST)] [General] [Info] Looking in: [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/flutter_issues [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/flutter_issues/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/flutter/bin/ [15:58:50 GMT+0800 (CST)] [General] [Info] /Applications/MacVim.app/Contents/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Library/Android/sdk/platform-tools [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Library/Android/sdk/platform-tools/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Library/Python/2.7/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/flutter/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/local/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/local/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/sbin [15:58:50 GMT+0800 (CST)] [General] [Info] /sbin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/depot_tools [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/depot_tools/bin [15:58:50 GMT+0800 (CST)] [General] [Info] Candidate paths to be post-filtered: [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/flutter [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/flutter [15:58:50 GMT+0800 (CST)] [General] [Info] Found at /Users/qigengxin/Documents/Github [15:58:50 GMT+0800 (CST)] [General] [Info] Returning SDK path /Users/qigengxin/Documents/Github for flutter [15:58:50 GMT+0800 (CST)] [General] [Info] Searching for dart [15:58:50 GMT+0800 (CST)] [General] [Info] Looking in: [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/bin/cache/dart-sdk [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/bin/cache/dart-sdk/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Applications/MacVim.app/Contents/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Library/Android/sdk/platform-tools [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Library/Android/sdk/platform-tools/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Library/Python/2.7/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/flutter/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/local/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/local/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /bin [15:58:50 GMT+0800 (CST)] [General] [Info] /usr/sbin [15:58:50 GMT+0800 (CST)] [General] [Info] /sbin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/depot_tools [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/depot_tools/bin [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/bin/cache/dart-sdk [15:58:50 GMT+0800 (CST)] [General] [Info] /Users/qigengxin/Documents/Github/bin/cache/dart-sdk/bin [15:58:50 GMT+0800 (CST)] [General] [Info] Candidate paths to be post-filtered: [15:58:50 GMT+0800 (CST)] [General] [Info] Returning SDK path undefined for dart

DanTup commented 5 years ago

I can't reproduce this with your project, however I believe the issue is this:

[15:58:50 GMT+0800 (CST)] [General] [Info] Found at /Users/qigengxin/Documents/Github
[15:58:50 GMT+0800 (CST)] [General] [Info] Returning SDK path /Users/qigengxin/Documents/Github for flutter

Do you have a Flutter binary or SDK in /Users/qigengxin/Documents/Github?

voiddog commented 5 years ago

No flutter sdk in Github directory, but has flutter engine.

The strange thing is, if I delete the flutter folder under my demo project, it works fine.

DanTup commented 5 years ago

The strange thing is, if I delete the flutter folder under my demo project, it works fine.

That is definitely strange. I may need to add more logging to understand what's happening.

Could you confirm:

  1. What does the flutter entry in the .packages file for your project look like?
  2. What folder are you opening in VS Code (flutter_issues, or something above it?)
  3. Is there a file at /Users/qigengxin/Documents/Github/bin/flutter? If so, have you created any symlinks to it from anywhere?
voiddog commented 5 years ago

Here is the infomation: 1:

flutter:file:///Users/qigengxin/flutter/packages/flutter/lib/

2: I opening flutter_issues in VS Code 3 Here is my file list in Github:

total 0
drwxr-xr-x   21 qigengxin  staff   672 10 24 18:17 AndroidLib
drwxr-xr-x   18 qigengxin  staff   576 10 19 16:44 DampingSystem
drwxr-xr-x   34 qigengxin  staff  1088  2 19 15:05 FlutterEngine
drwxr-xr-x   15 qigengxin  staff   480  1 15 10:21 HexoBlog
drwxr-xr-x    6 qigengxin  staff   192  2 12 11:49 MyFlutterEngine
drwxr-xr-x   13 qigengxin  staff   416 10 18 17:34 PixivMuzei
drwxr-xr-x   24 qigengxin  staff   768 10 18 15:47 SmartRefreshLayout
drwxr-xr-x   15 qigengxin  staff   480  1 25 10:27 Streams-Block-Reactive-Programming-in-Flutter
drwxr-xr-x    6 qigengxin  staff   192 10 15 10:34 VPN2SS
drwxr-xr-x    6 qigengxin  staff   192  1 31 15:39 VirtualHook
drwxr-xr-x   24 qigengxin  staff   768 10 22 15:29 android-architecture-components
drwxr-xr-x   31 qigengxin  staff   992  1 21 16:14 blog
drwxr-xr-x  206 qigengxin  staff  6592  2 12 10:07 depot_tools
drwxr-xr-x   15 qigengxin  staff   480 11 23 17:16 enjarify
drwxr-xr-x   18 qigengxin  staff   576  2 19 16:26 flutter_issues
drwxr-xr-x   15 qigengxin  staff   480  1 29 21:12 flutter_staggered_grid_view
drwxr-xr-x   24 qigengxin  staff   768 10 15 11:53 gradle
drwxr-xr-x   18 qigengxin  staff   576  2 12 12:46 hybrid_stack_manager
drwxr-xr-x   19 qigengxin  staff   608  9 30 16:14 iTerm2-Color-Schemes
drwxr-xr-x   54 qigengxin  staff  1728 10 16 18:43 kotlin
drwxr-xr-x   17 qigengxin  staff   544  2 11 18:24 macos-sdk
drwxr-xr-x   19 qigengxin  staff   608  1 30 14:40 pixiv_flutter
drwxr-xr-x   15 qigengxin  staff   480 11 19 15:26 plugins
drwxr-xr-x   20 qigengxin  staff   640 10  1 11:08 shadowsocks
drwxr-xr-x   23 qigengxin  staff   736 10 22 15:21 vlayout
voiddog commented 5 years ago

issure with flutter folder include

works fine

Just deleted the flutter directory, no other changes have been made.

DanTup commented 5 years ago

Ok thanks - I think I understand what's happening though I haven't been able to trigger it locally yet. When we look for flutter we don't exclude directories, so with a folder named flutter in any of the paths we search, we may consider it an SDK.

The fix should be simple, but I'd like to make sure I can repro locally and add a test first. Thanks for the help investigating!

DanTup commented 5 years ago

Ok, I can repro - but because I had a Dart SDK also on my PATH, the failure was different (it found an SDK, but the wrong one).

If you want to try this build, it should solve the problem:

https://github.com/Dart-Code/Dart-Code/releases/tag/v2.24.0-dev.1

Download the vsix file, then run the Extensions: Install from VSIX command in the VS Code command palette and select the vsix file. Then click the Reload button on the notification.

Let me know if it solves the problem. It's fine to stick with this version, as it will automatically update when I push a stable release.

voiddog commented 5 years ago

Thanks, it works!

DanTup commented 5 years ago

Excellent! Thanks for the help! 👍

vikaskrsharma commented 1 year ago

Hi @DanTup , I am also facing the same issue. When initialising flutter project, Getting error "Could not find Dart in your flutter SDK". I also tried your fix but it is still not working and getting same error. I have put flutter sdk in BuyerApp folder but Dart path is getting returned as undefined. Can you please suggest what can be done here or how can i resolve this issue?

[10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] Found at: [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/buyer-app [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] Candidate paths to be post-filtered: [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] Found at /Users/vikassharma/Documents/Repos/BuyerApp/flutter [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] Returning SDK path /Users/vikassharma/Documents/Repos/BuyerApp/flutter for flutter [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] Searching for dart [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] Looking for dart in: [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin/cache/dart-sdk [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin/cache/dart-sdk/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Library/Applications/PostgreSQL/14/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /usr/local/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /usr/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /usr/sbin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /sbin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Library/Apple/usr/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Learning/ST/UdemySelenium/MavenSetup/apache-maven-3.8.7/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin/cache/dart-sdk [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin/cache/dart-sdk/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] Found at: [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin/cache/dart-sdk/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin/cache/dart-sdk/bin [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] Candidate paths to be post-filtered: [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin/cache/dart-sdk [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] /Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin/cache/dart-sdk [10:47:08 GMT+0530 (India Standard Time)] [General] [Info] Returning SDK path undefined for dart Mon Mar 13 2023 [10:49:05 GMT+0530 (India Standard Time)] Log file ended

DanTup commented 1 year ago

@vikaskrsharma please open a new issue and include the full output of running "/Users/vikassharma/Documents/Repos/BuyerApp/flutter/bin/flutter doctor" from a terminal and then an updated log file (as above, but after running doctor). Thanks!

vikaskrsharma commented 1 year ago

@DanTup For now, my issue got resolved by downgrading flutter sdk from 3.7 version to 3.3 version. So the issue is only with 3.7 version sdk.

DanTup commented 1 year ago

@vikaskrsharma if there's an issue here, I'd really like to understand and fix it (otherwise you may be stuck on an old version forever). If you're able to try again when you have time and file an issue, that would be appreciated.

vikaskrsharma commented 1 year ago

Sure, will try to do it.