Flutter / VSC Could not find Dart in your Flutter SDK

1,843

Definitely just a merge conflict so dont be panic. Run git status and post the result first.

Share:
1,843
Juju
Author by

Juju

Updated on December 16, 2022

Comments

  • Juju
    Juju 12 months

    I have a flutter project set up with Git in visual studio code. I tried to pull from Git and I guess I got a merge conflict.

    Now I get the error "Could not find Dart in your Flutter SDK. Please run 'flutter doctor' in the terminal then reload the project once all issues are resolved"

    And when run flutter doctor:

    Downloading Dart SDK from Flutter engine <<<<<<< HEAD
    b863200c37df4ed378042de11c4e9ff34e4e58c9
    =======
    2994f7e1e682039464cb25e31a78b86a3c59b695
    >>>>>>> 27321ebbad34b0a3fafe99fac037102196d655ff...
    curl: (3) URL using bad/illegal format or missing URL
    
    Failed to retrieve the Dart SDK from: https://storage.googleapis.com/flutter_infra/flutter/<<<<<<< HEAD
    b863200c37df4ed378042de11c4e9ff34e4e58c9
    =======
    2994f7e1e682039464cb25e31a78b86a3c59b695
    >>>>>>> 27321ebbad34b0a3fafe99fac037102196d655ff/dart-sdk-darwin-x64.zip
    If you're located in China, please see this page:
      https://flutter.dev/community/china
    

    How can I fix this issue? Any help is appreciated.

    Git status:

    On branch master
    Your branch is up to date with 'origin/master'.
    
    nothing to commit, working tree clean
    

    Run git clean -xfd git stash save --keep-index git stash drop git pull flutter doctor in Flutter directory

    Output:

    Juju@Juju-MacBook-Pro flutter % git clean -xfd
    Removing .DS_Store
    Removing .idea/
    Skipping repository .pub-cache/git/goldens-c47f1308188dca65b3899228cac37f252ea8b411
    Removing .pub-cache/git/cache
    Removing .pub-cache/_temp
    Removing .pub-cache/hosted
    Removing bin/cache/
    Removing dev/automated_tests/pubspec.lock
    Removing dev/benchmarks/complex_layout/complex_layout.iml
    Removing dev/benchmarks/complex_layout/pubspec.lock
    Removing dev/benchmarks/macrobenchmarks/pubspec.lock
    Removing dev/benchmarks/microbenchmarks/pubspec.lock
    Removing dev/bots/bots.iml
    Removing dev/bots/pubspec.lock
    Removing dev/customer_testing/pubspec.lock
    Removing dev/devicelab/devicelab.iml
    Removing dev/devicelab/pubspec.lock
    Removing dev/integration_tests/android_semantics_testing/pubspec.lock
    Removing dev/integration_tests/android_splash_screens/splash_screen_kitchen_sink/pubspec.lock
    Removing dev/integration_tests/android_splash_screens/splash_screen_load_rotate/pubspec.lock
    Removing dev/integration_tests/android_splash_screens/splash_screen_trans_rotate/pubspec.lock
    Removing dev/integration_tests/android_views/pubspec.lock
    Removing dev/integration_tests/channels/pubspec.lock
    Removing dev/integration_tests/codegen/pubspec.lock
    Removing dev/integration_tests/external_ui/pubspec.lock
    Removing dev/integration_tests/flavors/pubspec.lock
    Removing dev/integration_tests/image_loading/pubspec.lock
    Removing dev/integration_tests/ios_add2app/flutterapp/pubspec.lock
    Removing dev/integration_tests/named_isolates/pubspec.lock
    Removing dev/integration_tests/platform_interaction/pubspec.lock
    Removing dev/integration_tests/release_smoke_test/pubspec.lock
    Removing dev/integration_tests/simple_codegen/pubspec.lock
    Removing dev/integration_tests/ui/pubspec.lock
    Removing dev/integration_tests/web/pubspec.lock
    Removing dev/manual_tests/android.iml
    Removing dev/manual_tests/manual_tests.iml
    Removing dev/manual_tests/pubspec.lock
    Removing dev/snippets/pubspec.lock
    Removing dev/tools/gen_keycodes/pubspec.lock
    Removing dev/tools/pubspec.lock
    Removing dev/tools/tools.iml
    Removing dev/tools/vitool/pubspec.lock
    Removing examples/catalog/catalog.iml
    Removing examples/catalog/pubspec.lock
    Removing examples/flutter_gallery/android.iml
    Removing examples/flutter_gallery/flutter_gallery.iml
    Removing examples/flutter_gallery/pubspec.lock
    Removing examples/flutter_view/flutter_view.iml
    Removing examples/flutter_view/pubspec.lock
    Removing examples/hello_world/android.iml
    Removing examples/hello_world/hello_world.iml
    Removing examples/hello_world/pubspec.lock
    Removing examples/image_list/pubspec.lock
    Removing examples/layers/layers.iml
    Removing examples/layers/pubspec.lock
    Removing examples/platform_channel/android.iml
    Removing examples/platform_channel/platform_channel.iml
    Removing examples/platform_channel/pubspec.lock
    Removing examples/platform_channel_swift/platform_channel_swift.iml
    Removing examples/platform_channel_swift/pubspec.lock
    Removing examples/platform_view/android.iml
    Removing examples/platform_view/full_platform_view.iml
    Removing examples/platform_view/pubspec.lock
    Removing examples/stocks/android.iml
    Removing examples/stocks/pubspec.lock
    Removing examples/stocks/stocks.iml
    Removing flutter_root.iml
    Removing packages/flutter/coverage/
    Removing packages/flutter/flutter.iml
    Removing packages/flutter/pubspec.lock
    Removing packages/flutter_driver/flutter_driver.iml
    Removing packages/flutter_driver/pubspec.lock
    Removing packages/flutter_goldens/pubspec.lock
    Removing packages/flutter_goldens_client/pubspec.lock
    Removing packages/flutter_localizations/flutter_localizations.iml
    Removing packages/flutter_localizations/pubspec.lock
    Removing packages/flutter_test/flutter_test.iml
    Removing packages/flutter_test/pubspec.lock
    Removing packages/flutter_test/test/test_config/project_root/pubspec.lock
    Removing packages/flutter_tools/.dart_tool/
    Removing packages/flutter_tools/.packages
    Removing packages/flutter_tools/flutter_tools.iml
    Removing packages/flutter_tools/pubspec.lock
    Removing packages/flutter_tools/test/data/asset_test/main/pubspec.lock
    Removing packages/fuchsia_remote_debug_protocol/pubspec.lock
    Juju@Juju-MacBook-Pro flutter % git stash save --keep-index
    bin/internal/engine.version: needs merge
    dev/bots/test.dart: needs merge
    packages/flutter_tools/lib/src/commands/attach.dart: needs merge
    packages/flutter_tools/lib/src/context_runner.dart: needs merge
    packages/flutter_tools/lib/src/ios/devices.dart: needs merge
    packages/flutter_tools/lib/src/macos/cocoapods.dart: needs merge
    packages/flutter_tools/lib/src/mdns_discovery.dart: needs merge
    packages/flutter_tools/pubspec.yaml: needs merge
    packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart: needs merge
    packages/flutter_tools/test/general.shard/ios/devices_test.dart: needs merge
    packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart: needs merge
    packages/flutter_tools/test/general.shard/mdns_discovery_test.dart: needs merge
    bin/internal/engine.version: needs merge
    dev/bots/test.dart: needs merge
    packages/flutter_tools/lib/src/commands/attach.dart: needs merge
    packages/flutter_tools/lib/src/context_runner.dart: needs merge
    packages/flutter_tools/lib/src/ios/devices.dart: needs merge
    packages/flutter_tools/lib/src/macos/cocoapods.dart: needs merge
    packages/flutter_tools/lib/src/mdns_discovery.dart: needs merge
    packages/flutter_tools/pubspec.yaml: needs merge
    packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart: needs merge
    packages/flutter_tools/test/general.shard/ios/devices_test.dart: needs merge
    packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart: needs merge
    packages/flutter_tools/test/general.shard/mdns_discovery_test.dart: needs merge
    bin/internal/engine.version: unmerged (9b47683e091e31759027947b50967b113e5c4a0e)
    bin/internal/engine.version: unmerged (446391086d1083a9efd4e552d90c763a1a5b0353)
    bin/internal/engine.version: unmerged (cf062e01a0c732cce453bb1c83a15816aaef7ffd)
    dev/bots/test.dart: unmerged (c546075ce7839a936a31ae5df42c2797ad288645)
    dev/bots/test.dart: unmerged (aef335fd140f9054ac355231dd37a71f6505c9d9)
    dev/bots/test.dart: unmerged (ee779205405e32b833e783409a50ab1147dc0e1d)
    packages/flutter_tools/lib/src/commands/attach.dart: unmerged (dd68a476a86d24e8ea787970ad4209fd532cc505)
    packages/flutter_tools/lib/src/commands/attach.dart: unmerged (20a23a31fa261bcd8ce90a6913b6da8a809875be)
    packages/flutter_tools/lib/src/commands/attach.dart: unmerged (5c9e24302d0b51e47b95fefbfd19aa5098d2bca3)
    packages/flutter_tools/lib/src/context_runner.dart: unmerged (83985e5fce6f592ecb4cd1ee4e909aa4ce11740b)
    ...
    fatal: git-write-tree: error building trees
    Cannot save the current index state
    Juju@Jujus-MacBook-Pro flutter % git stash drop
    No stash entries found.
    Juju@Jujus-MacBook-Pro flutter % git pull
    error: Pulling is not possible because you have unmerged files.
    hint: Fix them up in the work tree, and then use 'git add/rm <file>'
    hint: as appropriate to mark resolution and make a commit.
    fatal: Exiting because of an unresolved conflict.
    

    Solution

    git reset head --hard
    

    in flutter directory and afterwards

    flutter doctor 
    

    in the project worked for me! It reinstalled the flutter sdk automatically.

  • Q.u.a.n.g L.
    Q.u.a.n.g L. almost 4 years
    How about the git status in the flutter sdk project?
  • Juju
    Juju almost 4 years
    What exactly do you mean? This is when I have my flutter project open in vsc and type in "git status" into the terminal. Sorry I'm a beginner...
  • Q.u.a.n.g L.
    Q.u.a.n.g L. almost 4 years
    Since there's no conflict in the project, I doubt the merge conflict happens in the flutter sdk folder. Flutter install directory is in an inconsistent state and that causes all kinds of troubles. Go there and take some reset and re pull. Check this section. github.com/flutter/flutter/wiki/…
  • Juju
    Juju almost 4 years
    Did all the commands. Updated the post with the output. How can I fix the conflict?
  • Q.u.a.n.g L.
    Q.u.a.n.g L. almost 4 years
    Hmm. Try git reset head --hard and then git status
  • Q.u.a.n.g L.
    Q.u.a.n.g L. almost 4 years
    If it still not works, the final solution is just remove the current sdk folder and re-download...
  • Juju
    Juju almost 4 years
    git reset head --hardin flutter directory and afterwards flutter doctorin the project worked for me! It reinstalled the flutter sdk automatically. Thanks