Repository navigation
"Flutter users should use flutter pub get" when fetching packages for a Dart project in a Pub Workspace that also uses Flutter #5973
Description
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
DanTup commentedon Mar 12, 2026
I just tested, and as long as
FLUTTER_ROOTis set,dart pub getseems 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 usingflutterentirely (as long as this works back for all versions we support).DanTup commentedon Mar 12, 2026
@FMorschel I'm actually unable to reproduce this. I created a Pub Workspace with a Dart and Flutter project, I deleted all
.dart_toolfolders so it can't find Flutter, and then I edited the pubspec.yaml in the Dart project and it correctly fetched packages (usingdart pub get).I believe this worked because we should've set
FLUTTER_ROOT.Question - is it possible you have a
FLUTTER_ROOTset 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.FMorschel commentedon Mar 12, 2026
I don't think so because it is the same
puroenv 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
flutterfolder. I'm guessing there is some case where we are not setting it correctly or are not using the correctdartexecutable.I'm working on creating a repro for a similar case.
FMorschel commentedon Mar 12, 2026
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 thepubspec.yamlpub 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.
FMorschel commentedon Mar 12, 2026
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_overrideson the rootpubspec.yamluncommented.DanTup commentedon Mar 12, 2026
I'm a little confused then. In a non-Pub-Workspace, it should not be a requirement to use
flutter pub getin a pure Dart project, because there would be no Flutter references to resolve? The error for needing to usefluttershould only occur when there issdk: flutterin the pubspec.I tried cloning your
flutter_pub_get_exampleproject, 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_ROOTenv variable set (echo $env:FLUTTER_ROOTorecho $FLUTTER_ROOT), or have them define in any of yourenv/dart.envsettings?Otherwise, can you run the Dart: Capture Logs command while reproducing the issue?
Thanks!
FMorschel commentedon Mar 12, 2026
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
dartversion because noflutteris ever used.I don't have either.
I've deleted both
.dart_toolfolders, started capturing, ran thepub gettoast, and once it finished, saved the innerpubspec.yamlfile to see it resolving, then finally stopped capturing.Dart-Code-Log-2026-02-04 13-40-10.txt
DanTup commentedon Mar 12, 2026
@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
defaultisn'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 haveFLUTTER_ROOTset 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 runflutter 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.
FMorschel commentedon Mar 12, 2026
I found it. On my profile settings, though I don't remember adding those, so it must have been a while ago:
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).
FMorschel commentedon Mar 12, 2026
And then yes, if I try it with a terminal and
dart pub get, I see the same error.3 remaining items
DanTup commentedon Mar 12, 2026
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.
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).
FMorschel commentedon Mar 12, 2026
It was gone, I checked.
I'll do some testing. Thanks!
DanTup commentedon Mar 12, 2026
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!
FMorschel commentedon Mar 12, 2026
Same steps. Do you want me to capture a second log without that set?
FMorschel commentedon Mar 12, 2026
And BTW, on PowerShell, for that same
flutter_pub_get_example/examplepackage with no.dart_toolfolders anywhere:Always set FLUTTER_ROOT for child processes, overriding any existing …
[-]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[/+]DanTup commentedon Mar 12, 2026
Is the
dartonPATHhere the one fromflutter/bin? If so, that may be settingFLUTTER_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 pressingF5), you could check it definitely handles the original case you had.FMorschel commentedon Mar 12, 2026
The first one is my bleeding-edge version, the other two are from
puro, so we still don't haveFLUTTER_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.I'll try it out and let you know. Thanks much!
DanTup commentedon Mar 12, 2026
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
dartinside the Flutter SDK. So I guess a more similar test at the terminal would be running:This sets FLUTTER_ROOT to what you had, but then uses
dartfrom inside a "different" Flutter SDK (the one from your log).Although, this also seems odd to me:
We never intentionally use a Dart SDK that's not inside the Flutter SDK, so something seems a bit weird here 🙃
FMorschel commentedon Mar 12, 2026
That is the resolved
puropath. It caches thedartpart because it may be the exact same version across differentflutterhotfixes. This way it saves some space and download time. That is the exact version it resolves to; it is correct.FMorschel commentedon Mar 13, 2026
I've just tested, and it worked!
Thanks a lot!
DanTup commentedon Mar 13, 2026
Great, thanks for testing!