Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Terminal says pub: command not found after installing Dart

Errorpub: command not found

Short 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.

  • Applies to Dart 3.x, Flutter 3.3x, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 --version
  2. 2Match what you see, then jump to its fix

    1. 1dart --version works, but pub get or pub run says command not foundYou typed the old standalone commandFix
    2. 2command -v dart prints nothingThe Dart SDK is not installed on this machineFix

What does the error look like?

  • pub: command not found
  • dart: 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 --help

2Fix

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 package

3Verify

The command resolves dependencies without a not-found error.

dart pub get

Confirmed by dart.dev

Did this fix it?

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 dart

2Fix

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 dart

3Verify

A version prints.

dart --version

Confirmed by dart.dev

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.