Pub command is not found after installing dart-sdk

Posted on Aug 1, 2022

Question

I want to write a command line application on my Ubuntu machine but I encountered a problem when I was installing the dart sdk of dart 2 on linux mint 19.

After the installation I can't run the pub command from the terminal. I always get this error:

   Command 'pub' not found, did you mean:

command ‘puf’ from deb puf command ‘pdb’ from deb python command ‘publ’ from deb atfs command ‘pua’ from deb pglistener command ‘dub’ from deb dub command ‘pcb’ from deb pcb-gtk command ‘pcb’ from deb pcb-lesstif command ‘pudb’ from deb python-pudb

Try: sudo apt install <deb name>

I already tried some path settings from the internet but none of them work or only temporarily.

How can I fix this?

Answer

As someone mentioned in a comment to an (outdated) answer, the nowadays (due to Dart being supplied / integrated with / in Flutter now) suggested correct use of pub is to be called via the flutter command:

`flutter pub`

ie. to use gRPC / protobufs v3 w/ Dart / Flutter:

`flutter pub global activate protoc_plugin`