Skip to content

Improve failure if sdkPath is not a string #1732

Closed

Description

@shariarrazm

I installed Dart, flutter and PATH but when i want to create new flutter project from command palette i have this error "command 'flutter.createProject' not found" Even if i open a ready project the syntax is not working

Activity

  1. DanTup commented on May 21, 2019

    @DanTup
    Member

    @shariarrazm could you click Help -> Toggle Developer Tools and see if there are errors in the Console tab about failing to activate the extension?

    If you open an existing project (for example flutter_gallery from the flutter/examples folder), do you see any errors for that too? Do you get a popup with a "View Logs" button on it?

  2. added
    awaiting infoRequires more information from the customer to progress
    on May 21, 2019
  3. shariarrazm commented on May 21, 2019

    @shariarrazm
    Author
  4. DanTup commented on May 21, 2019

    @DanTup
    Member

    @shariarrazm Do you have any dart. settings in your VS Code user settings? If so, could you post them here? (I'm specifically interested in if you have dart.sdkPath set).

  5. shariarrazm commented on May 21, 2019

    @shariarrazm
    Author

    How can i find this?

  6. DanTup commented on May 21, 2019

    @DanTup
    Member

    Press Cmd+, (cmd+comma) to open your VS Code settings. It's a JSON file. See if you have "dart.sdkPath" anywhere in there.

  7. shariarrazm commented on May 21, 2019

    @shariarrazm
    Author

    {
    "dart.sdkPath": [
    "/Users/ShariarRazm1/Desktop/Flutter/flutter"
    ],
    "[dart]": {},
    "files.associations": {
    "*.dart": "dart"
    }
    }

  8. DanTup commented on May 21, 2019

    @DanTup
    Member

    @shariarrazm remove the [square brackets] from around dart.sdkPath, like this:

    "dart.sdkPath": "/Users/ShariarRazm1/Desktop/Flutter/flutter",

    That value should be a string not a string[] array.

    Let me know if that helps!

  9. DanTup commented on May 21, 2019

    @DanTup
    Member

    Actually, that's probably not a valid path - you've put a Flutter SDK in dart.sdkPath. Change it to flutter.sdkPath:

    "dart.flutterSdkPath": "/Users/ShariarRazm1/Desktop/Flutter/flutter",

    Note: If you have added Flutter's bin folder to your PATH env variable, you might not need that setting at all.

  10. shariarrazm commented on May 21, 2019

    @shariarrazm
    Author

    i have this in my .bash_profile export
    PATH=/Users/ShariarRazm1/desktop/flutter/bin:$PATH

  11. DanTup commented on May 21, 2019

    @DanTup
    Member

    In that case, you might not need to set dart.flutterSdkPath, but it depends whether the PATH in your bash profile applies to your desktop. The simplest way is just to probably add the setting - but if you ever move Flutter from your desktop, you'll need to update it.

    The setting you want is:

    "dart.flutterSdkPath": "/Users/ShariarRazm1/Desktop/Flutter/flutter",

    If you want to set the Dart SDK too, it should be:

    "dart.sdkPath": "/Users/ShariarRazm1/Desktop/Flutter/flutter/bin/cache/dart-sdk",

    Let me know if these resolve your issue.

  12. shariarrazm commented on May 21, 2019

    @shariarrazm
    Author

    still i have this problem
    Screenshot 2019-05-21 at 17 01 41

  13. DanTup commented on May 21, 2019

    @DanTup
    Member

    @shariarrazm can you click Help -> Toggle Dev Tools and check the console again, to see if there's a different error?

  14. shariarrazm commented on May 21, 2019

    @shariarrazm
    Author

    Screenshot 2019-05-21 at 17 42 15

  15. DanTup commented on May 21, 2019

    @DanTup
    Member

    @shariarrazm that looks like the same error. Can you try restarting VS Code, and if you see the same issue, run the Open Workspace Settings command in VS Code and ensure that your current workspace doesn't also have a bad dart.sdkPath value set.

  16. shariarrazm commented on May 21, 2019

    @shariarrazm
    Author

    Now its working! Thank you very much!

  17. DanTup commented on May 21, 2019

    @DanTup
    Member

    Great! Do open issues if you have any other problems :-)

  18. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    and removed
    awaiting infoRequires more information from the customer to progress
    on May 21, 2019
  19. added this to the v3.1.0 milestone on May 21, 2019
  20. changed the title [-]VSCode command 'flutter.createProject' not found[/-] [+]Improve failure if sdkPath is not a string[/+] on May 21, 2019
  21. DanTup commented on May 21, 2019

    @DanTup
    Member

    I'm gonna reopen this to improve the failure since it seems like VS Code wasn't giving you a warning when you had an array in that setting.

  22. reopened this on May 21, 2019
  23. DanTup commented on May 22, 2019

    @DanTup
    Member

    Seems like VS Code is validating this for me:

    Screenshot 2019-05-22 at 9 11 16 am

    However in addition, resolvePath now has a check for strings so will treat non-strings as undefined in the next version - which would avoid the original failure (instead, just notifying that it can't find the SDK). So nothing to do here now.

  24. chubutin commented on Apr 15, 2020

    @chubutin

    In that case, you might not need to set dart.flutterSdkPath, but it depends whether the PATH in your bash profile applies to your desktop. The simplest way is just to probably add the setting - but if you ever move Flutter from your desktop, you'll need to update it.

    The setting you want is:

    "dart.flutterSdkPath": "/Users/ShariarRazm1/Desktop/Flutter/flutter",

    If you want to set the Dart SDK too, it should be:

    "dart.sdkPath": "/Users/ShariarRazm1/Desktop/Flutter/flutter/bin/cache/dart-sdk",

    Let me know if these resolve your issue.

    with both sdk configured and flutter in my path the issue was resolved. Thanks man

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions