Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pub command is not found after installing dart-sdk

Tags:

path

ubuntu

dart

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?

like image 901
ruttydm Avatar asked Jul 11 '18 21:07

ruttydm


People also ask

How do I install pub darts?

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.

Can't find a command named dart?

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.

What is pub in dart?

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.

How do you set up a dart sdk?

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.


3 Answers

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` 
like image 109
MaxZ Avatar answered Sep 17 '22 11:09

MaxZ


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

like image 28
theredcap Avatar answered Sep 18 '22 11:09

theredcap


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

like image 29
Aggieborn Avatar answered Sep 18 '22 11:09

Aggieborn