I am seeing this error message when trying to open DevTools from Visual Studio Code:


I tried running flutter pub global activate devtools but this didn't fix the issue.
I also tried running flutter pub global run devtools, but then I see this other error:
pub finished with exit code 65
I am not sure which other information is needed, so please let me know in case I need to provide anything else
Can you try running pub global activate devtools and if that completes without error, restart VS Code and try again. I suspect your pub cache may have a broken version of DevTools.
@mit-mit FYI, I've had quite a few reports lately where people seem to have copies of devtools in pub cache missing the pubspec.yaml and it needs to be reactivated (for ex. see #2398, #2128). I've implemented a prompt to help fix this in the next version, though it feels like there have been more reports in the last week or so than previous. I'm not sure what causes it (besides nuking the pub-cache, but I'm not sure if that's common).
Is pub global activate devtools the same as flutter pub global activate devtools? I already tried the second, and it indeed completes without errors. If I try running without the flutterat the beginning, I get this error, presumably because I am missing something on my Path environment variable:
The term 'pub' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I was able to fix this same issue with the commands you referenced on the other threads @DanTup, however my path to pub was different:
/usr/local/flutter/bin/cache/dart-sdk/bin/pub
Thanks
I also solved similar issue by running pub global activate devtools.
In my case pub is at /Applications/flutter/bin/cache/dart-sdk/bin/pub
If you are still trying to locate pub, this post may be helpful:
https://stackoverflow.com/questions/50321966/where-is-darts-sdk-located-within-flutter-folder
Is
pub global activate devtoolsthe same asflutter pub global activate devtools?
It depends how you installed Flutter, but if running flutter pub didn't fix it, I would expect pub to. flutter pub and pub may have different pub-cache folders, and VS Code always uses pub when running DevTools (because it can be launched from non-Flutter apps and we don't want to maintain two activated versions).
If pub isn't in your PATH, you'll need to provide the full path. That path may vary depending on where you've installed Flutter, but it's at (flutter sdk)/bin/cache/dart-sdk/bin/pub.
Please let me know if you still have issues launching in VS Code after running pub global activate devtools (not flutter pub). This will become easier in the next version of VS Code.
If anyone knows why pub thinks they have DevTools installed but does not have a pubspec, I'd love to understand why this is happening so much lately. Have you manually deleted your pub cache folders or anything similar?
Ok, I've figured out what's happening.
The more recent failures to activate are not a missing pubspec as the previous reports were (I noticed now there's a different error code), but actually a bad release of DevTools this week (v0.2.4) which fails to load with an error.
The updated version of DevTools was published as version 0.2.4+1 but Dart-Code considers this version to be equal to 0.2.4 because it uses a standard semver library (which differs slightly from pubs version handling) which means it isn't auto-updated before running (FYI @jacob314 - what I said yesterday about auto-updating was slightly incorrect because of this).
I'll try to improve the version check to more closely reflect how Pub works. In the meantime, the best fix for this is still to run pub global activate devtools (without a flutter prefix).
What if the fixed version (in our case version 0.2.4+1) is not available yet and I have already upgraded to the bad version?
How can I downgrade my devtools to a previous working version?
@DanTup Please let me know whether it is possible.
What if the fixed version (in our case version 0.2.4+1) is not available yet and I have already upgraded to the bad version?
The new version is already published on Pub, but if you're using a mirror or something that prevents you getting it, you should be able to downgrade to the previous version with pub global activate devtools 0.2.3.
Running pub global activate devtools without flutter in the beginning fixed the issue for me.
Thank you very much for the help! :)
Closing this as fixed by https://github.com/Dart-Code/Dart-Code/issues/2430 and https://github.com/Dart-Code/Dart-Code/issues/2436 in the next version.
For those who are on windows, I had to go to the flutter folder, under flutter\bin\cache\dart-sdk\bin and launch the .\pub.bat global activate devtools. Then add the pub to path at C:\Users\<user_name>\AppData\Roaming\Pub\Cache\bin
@tdnghia98 I guess that's not on Roaming directory. It is on Local directory. And anyone can add path in this way %USERPROFILE%\AppData\Local\Pub\Cache\bin (copy and paste this). If that depends on the installation of flutter then he/she must check whether it is in Roaming or in Local
For this seeing this issue recently, it's caused by not having Chrome installed and the DevTools server is trying to launch Chrome. There's an open issue at https://github.com/flutter/devtools/issues/2405 which I've opened a PR for.
yeah I agree but till date I have used them in VS Code itself. but after flutter v 1.22 update I got this issue and then I installed Google Chrome. then it works.
The issue was introduced with a DevTools update that just happened to go out around the same time as the Flutter update. VS Code will have auto-updated your DevTools to the latest one and then hit this issue.
Installing Google Chrome is the only workaround I know of until the DevTools fix is available in a release.
I had the same problem. Try the following:
pub global activate devtools
Most helpful comment
The issue was introduced with a DevTools update that just happened to go out around the same time as the Flutter update. VS Code will have auto-updated your DevTools to the latest one and then hit this issue.
Installing Google Chrome is the only workaround I know of until the DevTools fix is available in a release.