Skip to content

Strange order in finding dart/flutter SDK #3367

Closed

Description

@Hamdor

Describe the bug
The extension selects the wrong flutter SDK. I expect my local checked out git version to be used.

To Reproduce
I can reproduce it as follows (locally on windows, my drive is E, probably works with C too):

  1. Put a downloaded version from flutter SDK here: E:/flutter
  2. Setup and clone a git version of the flutter SDK here: E:/flutter-git
  3. Setup PATH, it should contain "E:/flutter-git/flutter/bin", NOT E:/flutter
  4. I also have FLUTTER_ROOT setup, pointing to E:/flutter-git/flutter
  5. Start visual studio code ==> Wrong SDK is used

Expected behavior
I would have expected that the version from E:/flutter-git is used, since the PATH variable points there.

Additional information
I worked around this as follows:
Since I have the FLUTTER_ROOT variable set locally, I moved the process.env.FLUTTER_ROOT to second position in
src\extension\sdk\utils.ts@246

Versions (please complete the following information):

  • VS Code version: 1.57.0-insider
  • Dart extension version: e8fd4e9
  • Dart/Flutter SDK version: 2.14.0-153.0.dev (dev)

Activity

  1. DanTup commented on May 28, 2021

    @DanTup
    Member

    If you run the Dart: Open Extension Log command it'll open a log file that shows all the places searched. My guess is that you have not run flutter packages get in your project using the Git version of Flutter, so it's picking up the one used (it reads the .packages/.dart_tool/package_config.json to ensure it uses the same version you've been using there). This is expected since that's the one the analyzer will be using.

    If you want to override/easily switch SDKs within a workspace, you can use the dart.flutterSdkPath/dart.flutterSdkPaths settings.

  2. added
    awaiting infoRequires more information from the customer to progress
    on May 28, 2021
  3. Hamdor commented on May 29, 2021

    @Hamdor
    ContributorAuthor

    My guess is that you have not run flutter packages get in your project using the Git version of Flutter, so it's picking up the one used (it reads the .packages/.dart_tool/package_config.json to ensure it uses the same version you've been using there). This is expected since that's the one the analyzer will be using.

    That was the problem, I did not know that the extension uses these files.

    If you want to override/easily switch SDKs within a workspace, you can use the dart.flutterSdkPath/dart.flutterSdkPaths settings.

    Thanks, I have not seen that. Maybe this option should be added to the README.md or to https://dartcode.org/faq/ to be better visible. What do you think?

  4. added
    in docs / websiteRelates to documentation, including the Dart Code website
    and removed
    awaiting infoRequires more information from the customer to progress
    on Jun 1, 2021
  5. added this to the v3.24.0 milestone on Jun 1, 2021
  6. DanTup commented on Jun 28, 2021

    @DanTup
    Member

    I updated the DAQ at https://dartcode.org/faq/ to have a little more detail on the search for SDKs. Thanks!

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

    in docs / websiteRelates to documentation, including the Dart Code website

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions