Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install pub (command line usage) for Dart on Ubuntu web-server

I've followed the instructions here (under the Linux tab) on installing Dart onto a Ubuntu web-server.

Dart itself works fine, but I can't use Pub commands (only Dart commands). How can I install Pub for the server?

like image 260
Will Squire Avatar asked Feb 11 '15 23:02

Will Squire


People also ask

How to install pub in ubuntu?

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. Right click on dart .

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.


3 Answers

Here are Dart’s installation instructions for 64bit version of Ubuntu using the Aptitude (apt) package manager (as found on the website):

# Enable HTTPS for apt. 
$ sudo apt-get update 
$ sudo apt-get install apt-transport-https 

# Get the Google Linux package signing key. 
$ sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' 

# Set up the location of the stable repository.
$ sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list' 
$ sudo apt-get update 
$ sudo apt-get install dart

After this though, it’s likely that the Pub commands will not work in the terminal even if the Dart language does (yours might be different, try entering ‘pub –-help’ to see). If this is the case, Pub can be enabled manually by adding Dart to the ‘.profile’ PATH.

It’s likely that the newly installed Dart files will be located in the ‘/usr/lib/dart’ directory (do check this if unsure). Once known, edit the ‘.profile’ file by entering:

nano ~/.profile

This will edit the bash profile using nano (if installed, else use another command line file editor). Now at the bottom of the file, add:

export PATH="$PATH:/usr/lib/dart/bin"

When finished, you can check it has saved afterwards by entering ‘cat ~/.profile’. Now force the bash profile to reload by entering:

. ~/.profile

Enter ‘pub –help’ again to check and hopefully the Pub help information is shown. Thank you Günter Zöchbauer for the hint ;)

like image 115
Will Squire Avatar answered Oct 01 '22 07:10

Will Squire


I guess you just need to add the dart-sdk/bin directory to the path or alternatively create symlinks in /usr/bin for the Dart tools you want to have easily available.

like image 26
Günter Zöchbauer Avatar answered Oct 01 '22 06:10

Günter Zöchbauer


Another work-around is creating a link to pub

sudo ln -s /usr/lib/dart/bin/pub /usr/bin/pub

https://askubuntu.com/questions/56339/how-to-create-a-soft-or-symbolic-link

like image 30
SuperCode Avatar answered Oct 01 '22 07:10

SuperCode