Skip to content

"Flutter users should use flutter pub get" when fetching packages for a Dart project in a Pub Workspace that also uses Flutter #5973

Closed

Description

@FMorschel

Describe the bug
If a pub workspace contains flutter packages, we should use flutter pub instead of dart pub.

To Reproduce
Steps to reproduce the behavior:

If you'd like me to create a simple repro, I can.

Expected behavior
Even if the flutter package is not the one being saved (or shown in the IDE), we should detect it and make sure the workspace root pub commands are using flutter instead of dart.

Please complete the following information:

Workspace Environment
Dart Code extension: 3.131.20260304
Flutter extension: 3.131.20260303 (activated)

App: Visual Studio Code
App Host: desktop
Version: win 1.111.0

Workspace type: Dart, Flutter (LSP) (Multiroot)
Workspace name: vendas (Workspace)

Dart (3.11.0): C:\Users\felip_0vh5fa6\.puro\shared\caches\6c0baaebf70e0148f485f27d5616b3d3382da7bf\dart-sdk
Flutter (3.41.2): C:\Users\felip_0vh5fa6\.puro\envs\stable\flutter (SM G780F (android-arm64/android))

Output from 'dart info'

C:\Users\felip_0vh5fa6\.puro\shared\caches\6c0baaebf70e0148f485f27d5616b3d3382da7bf\dart-sdk\bin\dart.exe info

If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.

General info

  • Dart 3.11.0 (stable) (Mon Feb 9 00:38:07 2026 -0800) on "windows_x64"
  • on windows / "Windows 11 Pro" 10.0 (Build 26200)
  • locale is pt-BR

Project info

  • sdk constraint: '^3.10.0'
  • dependencies: async, bloc, brasil_fields, cached_network_image, cloud_firestore, collection, community_charts_flutter, connectivity_plus, convex_bottom_bar, cross_file, currency_text_input_formatter, dartz, device_info_plus, dio, dio_http_cache, direct_select, due_date, equatable, firebase_auth, firebase_core, flutter, flutter_custom_clippers, flutter_easyloading, flutter_keyboard_visibility, flutter_localizations, flutter_signature_pad, flutter_speed_dial, flutter_spinbox, flutter_staggered_grid_view, font_awesome_flutter, grouped_list, image, intl, location, logging, mailer, mask_text_input_formatter, material_design_icons_flutter, package_info_plus, path, path_provider, pdf, percent_indicator, provider, scoped_model, search_cep, share_plus, shared_preferences, sqflite, syncfusion_flutter_datepicker, syncfusion_localizations, time, tutorial_coach_mark, upgrader, url_launcher, validators, wakelock_plus, xml
  • dev_dependencies:
  • elided dependencies: 10

Process info

Memory CPU Elapsed time Command line
0 MB -- dart.exe
0 MB -- dart.exe
0 MB -- dart.exe
0 MB -- dart.exe
0 MB -- dart.exe
0 MB -- dart.exe
0 MB -- dart.exe
0 MB -- dartvm.exe
0 MB -- dartvm.exe
0 MB -- dartvm.exe
Output from 'flutter doctor'

C:\Users\felip_0vh5fa6\.puro\envs\stable\flutter\bin\flutter.bat doctor -v

[!] Flutter (Channel stable, 3.41.2, on Microsoft Windows [Version 10.0.26200.7840], locale pt-BR) [1.263ms]
    • Flutter version 3.41.2 on channel stable at C:\Users\felip_0vh5fa6\.puro\envs\stable\flutter
    ! Warning: `dart` on your path resolves to C:\Users\felip_0vh5fa6\dart\bin\dart.exe, which is not inside your current Flutter SDK checkout at C:\Users\felip_0vh5fa6\.puro\envs\stable\flutter. Consider adding C:\Users\felip_0vh5fa6\.puro\envs\stable\flutter\bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 90673a4eef (3 weeks ago), 2026-02-18 13:54:59 -0800
    • Engine revision 6c0baaebf7
    • Dart version 3.11.0
    • DevTools version 2.54.1
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[√] Windows Version (11 Pro 64-bit, 25H2, 2009) [10,6s]

[√] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [14,9s]
    • Android SDK at C:\Users\felip_0vh5fa6\AppData\Local\Android\sdk
    • Emulator version 36.4.9.0 (build_id 14788078) (CL:N/A)
    • Platform android-36.1, build-tools 36.1.0
    • Java binary at: C:\Users\felip_0vh5fa6\AppData\Local\Programs\Android Studio 2\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    • All Android licenses accepted.

[√] Chrome - develop for the web [214ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.20) [213ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.14.36705.20
    • Windows 10 SDK version 10.0.26100.0

[√] Connected device (5 available) [2,7s]
    • SM G780F (wireless) (mobile) • adb-RX8R30G5WDH-h0vKcv._adb-tls-connect._tcp • android-arm64  • Android 13 (API 33)
    • SM G780F (mobile)            • dev-phone:42541                              • android-arm64  • Android 13 (API 33)
    • Windows (desktop)            • windows                                      • windows-x64    • Microsoft Windows [Version 10.0.26200.7840]
    • Chrome (web)                 • chrome                                       • web-javascript • Google Chrome 143.0.7499.193
    • Edge (web)                   • edge                                         • web-javascript • Microsoft Edge 145.0.3800.82

[√] Network resources [1.145ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Activity

  1. added this to the v3.132.0 milestone on Mar 11, 2026
  2. added
    in flutterRelates to running Flutter apps
    in commandsRelates to commands (usually invoked from the command Palette)
    on Mar 11, 2026
  3. DanTup commented on Mar 12, 2026

    @DanTup
    Member

    I just tested, and as long as FLUTTER_ROOT is set, dart pub get seems to work in Flutter projects. So I think probably we just need to ensure that's set (I thought it already would be, but I guess not). That way, we could probably avoid using flutter entirely (as long as this works back for all versions we support).

  4. DanTup commented on Mar 12, 2026

    @DanTup
    Member

    @FMorschel I'm actually unable to reproduce this. I created a Pub Workspace with a Dart and Flutter project, I deleted all .dart_tool folders so it can't find Flutter, and then I edited the pubspec.yaml in the Dart project and it correctly fetched packages (using dart pub get).

    Image

    I believe this worked because we should've set FLUTTER_ROOT.

    Question - is it possible you have a FLUTTER_ROOT set that is not valid? We only set FLUTTER_ROOT if it's not already set, so an invalid value might result in the behaviour you see.

  5. added
    awaiting infoRequires more information from the customer to progress
    on Mar 12, 2026
  6. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    I don't think so because it is the same puro env I use for the Flutter SDK path. I'm working on creating a repro case where you can see this failing.

    I do have both my SDK-edge first on the path than my flutter folder. I'm guessing there is some case where we are not setting it correctly or are not using the correct dart executable.

    I'm working on creating a repro for a similar case.

  7. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    Here it is:

    Clone https://github.com/FMorschel/flutter_pub_get_example and you'll see the toast for pub get. Use it instead of the pubspec.yaml pub get. This is not a workspace yet, but I have a separate package I'll use for testing that, though I suspect the underlying problem is the same.

    And thinking a bit more, you maybe need that same path config to reproduce? I'm not entirely sure.

  8. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    Alright, for the workspace case, I guess we can use https://github.com/FMorschel/dependency_resolution.

    I originally found this problem in a project where the structure is exactly the same. Clone this to the latest commit I just pushed, and guarantee you don't have the workspace .dart_tool/.

    To make sure the whole thing is resolvable, you need to have the dependency_overrides on the root pubspec.yaml uncommented.

  9. DanTup commented on Mar 12, 2026

    @DanTup
    Member

    This is not a workspace yet

    I'm a little confused then. In a non-Pub-Workspace, it should not be a requirement to use flutter pub get in a pure Dart project, because there would be no Flutter references to resolve? The error for needing to use flutter should only occur when there is sdk: flutter in the pubspec.

    I tried cloning your flutter_pub_get_example project, but I can't reproduce any errors. (although, I'm also not sure how sound it is to have a Dart-only project depend on a Flutter one generally??).

    Can you double-check that you don't have a FLUTTER_ROOT env variable set (echo $env:FLUTTER_ROOT or echo $FLUTTER_ROOT), or have them define in any of your env/dart.env settings?

    Otherwise, can you run the Dart: Capture Logs command while reproducing the issue?

    Thanks!

  10. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    (although, I'm also not sure how sound it is to have a Dart-only project depend on a Flutter one generally??).

    From some pub packages that expose both a Flutter version and a Dart-only version, I've heard that it simply knows to only get the dart version because no flutter is ever used.

    Can you double-check that you don't have a FLUTTER_ROOT env variable set

    Image

    or have them define in any of your env/dart.env settings?

    I don't have either.

    I've deleted both .dart_tool folders, started capturing, ran the pub get toast, and once it finished, saved the inner pubspec.yaml file to see it resolving, then finally stopped capturing.

    Dart-Code-Log-2026-02-04 13-40-10.txt

  11. DanTup commented on Mar 12, 2026

    @DanTup
    Member

    @FMorschel do you know where that top one is coming from? We don't set env vars except for PATH in the terminal, but if it's being set somewhere else, that might be why we're not overriding it.

    And can you also check whether it's a real Flutter SDK, and that default isn't some kind of symlink or something? If so, I suspect that that's why it doesn't work correctly.

    Note: You can test this without VS Code. In a terminal, go into a *Flutter project, and run dart pub get. If you have FLUTTER_ROOT set to a real Flutter SDK, then it should work. If it's not set (or set to something that isn't a real SDK), it will probably tell you to run flutter pub get.

    One fix would be for Dart-Code to just always override it, ignoring any value the user has set. I'll have to check why we didn't do that originally first though.

  12. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    I found it. On my profile settings, though I don't remember adding those, so it must have been a while ago:

        "terminal.integrated.env.windows": {
            "FLUTTER_ROOT": "C:\\Users\\felip_0vh5fa6\\.puro\\envs\\default\\flutter"
        },
        "dart.env": {
            "FLUTTER_ROOT": "C:\\Users\\felip_0vh5fa6\\.puro\\envs\\default\\flutter"
        },

    I've removed them (not showing on the terminal anymore), and I still see the issue, though (so it would be just like the terminal at the bottom of the screenshot).

  13. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    And then yes, if I try it with a terminal and dart pub get, I see the same error.

  14. 3 remaining items

  15. removed
    awaiting infoRequires more information from the customer to progress
    on Mar 12, 2026
  16. DanTup commented on Mar 12, 2026

    @DanTup
    Member

    I restarted vscode for that, so things were tested correctly.

    Unfortunately I don't think that's the same here as VS Code persists the terminal environments. If you're still seeing the old value in the terminal, delete the terminal and create a new one and it should be gone.

    That specific default folder is a symlink, yes. But I'd expect it to work since it got to the flutter inner folder, but I might be wrong.

    I don't know the implementation of Pub, but given it's not working, I'm assuming it's doing something that doesn't like it. One way to confirm is to set it to a real path and see if the issue goes away. (it won't matter with my fix for Dart-Code, but it may from the terminal if you were going to keep it set explicitly).

  17. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    Unfortunately I don't think that's the same here as VS Code persists the terminal environments. If you're still seeing the old value in the terminal, delete the terminal and create a new one and it should be gone.

    It was gone, I checked.

    I don't know the implementation of Pub, but given it's not working, I'm assuming it's doing something that doesn't like it. One way to confirm is to set it to a real path and see if the issue goes away. (it won't matter with my fix for Dart-Code, but it may from the terminal if you were going to keep it set explicitly).

    I'll do some testing. Thanks!

  18. DanTup commented on Mar 12, 2026

    @DanTup
    Member

    Sorry, I totally misread your earlier comment 😄

    So to be clear, you have removed both of those FLUTTER_ROOTs, and restarted VS Code, and you still see the issue? If so, can you confirm exactly what the steps are (since we discussed a few different things above, workspaces and non-workspaces), and capture a current log?

    (I'm less sure my fix will fix it if you're seeing it when there's no FLUTTER_ROOT set)

    Thanks!

  19. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    I've deleted both .dart_tool folders, started capturing, ran the pub get toast, and once it finished, saved the inner pubspec.yaml file to see it resolving, then finally stopped capturing.

    Dart-Code-Log-2026-02-04 13-40-10.txt

    Same steps. Do you want me to capture a second log without that set?

  20. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    And BTW, on PowerShell, for that same flutter_pub_get_example/example package with no .dart_tool folders anywhere:

    $env:FLUTTER_ROOT = "C:\Users\felip_0vh5fa6\.puro\envs\default\flutter"
    dart pub get
    Resolving dependencies...
    Downloading packages...
      _fe_analyzer_shared 93.0.0 (97.0.0 available)
      analyzer 10.0.1 (11.0.0 available)
      meta 1.17.0 (1.18.1 available)
    Got dependencies!
    3 packages have newer versions incompatible with dependency constraints.
    Try `dart pub outdated` for more information.
  21. changed the title [-]Pub workspace root should use `flutter` when an inner package uses it[/-] [+]"Flutter users should use flutter pub get" when fetching packages for a Dart project in a Pub Workspace that also uses Flutter[/+] on Mar 12, 2026
  22. DanTup commented on Mar 12, 2026

    @DanTup
    Member

    And BTW, on PowerShell, for that same flutter_pub_get_example/example package with no .dart_tool folders anywhere:

    Is the dart on PATH here the one from flutter/bin? If so, that may be setting FLUTTER_ROOT.

    I've just pushed a fix for this, so if you can easily run from source (should just be cloning, running npm install, then opening the project in VS Code and pressing F5), you could check it definitely handles the original case you had.

  23. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    Is the dart on PATH here the one from flutter/bin? If so, that may be setting FLUTTER_ROOT.

    The first one is my bleeding-edge version, the other two are from puro, so we still don't have FLUTTER_ROOT (pingbird/puro#147).

    Also, I did the same just before without it, and it failed, so I'm really confident that the first line there (setting FLUTTER_ROOT) made it work.

    where.exe dart
    C:\Users\felip_0vh5fa6\dart\bin\dart.exe
    C:\Users\felip_0vh5fa6\.puro\envs\default\flutter\bin\dart
    C:\Users\felip_0vh5fa6\.puro\envs\default\flutter\bin\dart.bat
    

    I've just pushed a fix for this, so if you can easily run from source (should just be cloning, running npm install, then opening the project in VS Code and pressing F5), you could check it definitely handles the original case you had.

    I'll try it out and let you know. Thanks much!

  24. DanTup commented on Mar 12, 2026

    @DanTup
    Member

    Hmm, it does seem odd if setting that value in the terminal makes it work, but the same in VS Code did not.

    One thing that is different is that we'd have been using dart inside the Flutter SDK. So I guess a more similar test at the terminal would be running:

    $env:FLUTTER_ROOT = "C:\Users\felip_0vh5fa6\.puro\envs\default\flutter"
    C:\Users\felip_0vh5fa6\.puro\envs\stable\flutter\bin\cache\dart-sdk\bin\dart.exe pub get
    

    This sets FLUTTER_ROOT to what you had, but then uses dart from inside a "different" Flutter SDK (the one from your log).

    Although, this also seems odd to me:

    Dart (3.11.0): C:\Users\felip_0vh5fa6\.puro\shared\caches\6c0baaebf70e0148f485f27d5616b3d3382da7bf\dart-sdk
    Flutter (3.41.2): C:\Users\felip_0vh5fa6\.puro\envs\stable\flutter (SM G780F (android-arm64/android))
    

    We never intentionally use a Dart SDK that's not inside the Flutter SDK, so something seems a bit weird here 🙃

  25. FMorschel commented on Mar 12, 2026

    @FMorschel
    ContributorAuthor

    That is the resolved puro path. It caches the dart part because it may be the exact same version across different flutter hotfixes. This way it saves some space and download time. That is the exact version it resolves to; it is correct.

  26. FMorschel commented on Mar 13, 2026

    @FMorschel
    ContributorAuthor

    I've just tested, and it worked!

    Thanks a lot!

  27. DanTup commented on Mar 13, 2026

    @DanTup
    Member

    Great, thanks for testing!

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 commandsRelates to commands (usually invoked from the command Palette)in flutterRelates to running Flutter appsis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions