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?
To find the path to pub , you can install dart with your . deb installation file, and open the synaptic package manager (type sudo synaptic from the command-line; install synaptic first, if it's not installed— sudo apt-get install synaptic ), find dart in the Synaptic Package Manager.
Workaround It happens when the flutter and dart sdk is located in C:\ directory and your project is in the different directory like D:\ . Create project in same directory where your sdks located. EDIT: If you have the issue, the problem is your sdk path is not set.
Pub is the package manager for the Dart programming language, containing reusable libraries & packages for Flutter, AngularDart, and general Dart programs. Some basic command: Use pub get to get dependencies. Use pub upgrade to upgrade a dependency. Use pub publish to make your library available for others.
Create a New Project in Android StudioOpen Android Studio and click on Configure. Then, select Plugins. From the resulting screen, click on Flutter and click on Install. Click on Accept and then Yes to install the Dart plugin.
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`
Sometimes when you install dart
, you may also have a problem where the dart
command works but the pub
command does not work, this is because dart
is only present in the /usr/bin, to solve this simply make a symlink and to add pub command to this /usr/bin
directory.
sudo ln -s /usr/lib/dart/bin/pub /usr/bin/pub
Hope this helps
It's important to ensure that the dart SDK is in the PATH. You can easily test it by trying to use pub
or dart
.
One way to ensure it's in the PATH is by creating a .bashrc file in your user's folder.
Then add the following:
PATH=$PATH:/path/to/dart/installation/bin/folder
export PATH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With