Terminal says pub: command not found after installing Dart
pub: command not foundShort answer
The standalone pub program no longer exists in current Dart. Pub is a subcommand now, so run dart pub get for a Dart package or flutter pub get for a Flutter one. If dart itself is not found, the SDK is not installed, or you use Flutter, which already ships dart in its own bin folder.
Fix it fast
1Find out which cause you have
Check whether dart itself is found. That splits the problem into the old command name or a missing SDK.
command -v dart dart --version2Match what you see, then jump to its fix
What does the error look like?
pub: command not founddart: command not found
Cause 1 of 2
You typed the old standalone command
1Check
The standalone pub command has been removed. Dart's docs tell you to run pub through dart or flutter. Old tutorials still show the bare command.
dart pub --help2Fix
Put dart pub or flutter pub in front of the pub command, in scripts and CI files too.
dart pub get # Dart package
flutter pub get # Flutter package3Verify
The command resolves dependencies without a not-found error.
dart pub getConfirmed by dart.dev
Cause 2 of 2
The Dart SDK is not installed on this machine
1Check
If you only installed Flutter, dart lives in Flutter's bin folder. If you want a separate SDK on Debian or Ubuntu, Dart documents an apt repository.
command -v flutter
ls "$(dirname "$(command -v flutter)")" | grep -x dart2Fix
With Flutter, use its bundled dart. For a standalone SDK on Ubuntu, add Google's signing key and the Dart repository, then install the dart package.
sudo apt-get update && sudo apt-get install apt-transport-https gpg
wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/dart.gpg
echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list
sudo apt-get update && sudo apt-get install dart3Verify
A version prints.
dart --versionConfirmed by dart.dev
How do I stop it coming back?
- Use dart pub and flutter pub in README files, Makefiles and CI so no script depends on the old command.
- Pick one install route per machine (Flutter's SDK or the Dart package) so two copies do not disagree.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
Related fixes
Mobile apps
The terminal cannot find the flutter or dart command
zsh: command not found: flutter
The flutter and dart programs both live in the bin folder of the Flutter SDK, so one PATH entry gives you both.
3 causes, each with a fixMobile apps
flutter doctor warns that dart on your path is not in the Flutter SDK
Consider adding C:\flutter\bin to the front of your path.
flutter doctor found a dart program on your PATH that lives outside the Flutter SDK folder, usually a separate Dart SDK installed earlier in the list.
3 causes, each with a fixMobile apps
flutter doctor fails the Network resources check
A cryptographic error occurred while checking
The Network resources check sends a request to a fixed list of hosts and fails if one does not answer.
2 causes, each with a fixMobile apps
A Flutter command says it cannot find pubspec.yaml
This command should be run from the root of your Flutter project.
Flutter and Dart read pubspec.yaml from the current working directory.
3 causes, each with a fixMobile apps
Flutter keeps retrying 'pub upgrade' for its own tool
Got socket error trying to find package
The flutter command rebuilds its own tool and downloads packages from pub.dev to do it.
3 causes, each with a fixMobile apps
Terminal says fvm: command not found after installing FVM
zsh: command not found: fvm
The shell cannot find an fvm executable.
2 causes, each with a fix