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

匿名 (未验证) 提交于 2019-12-03 08:44:33

问题:

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?

回答1:

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.



回答2:

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 

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 



回答3:

dart, but just isn't in the path for some reason). To find the path to pub, you can install dart with your .deb installation file, and open the synaptic package managersudo apt-get install synaptic), find dart in the Synaptic Package Manager. Right click on dart. Click on properties. Go to the installed files tab. Look for pub to see where it's installed. Here's where mine is: /usr/lib/dart/bin/pub. The 'included files' tab while using gdebi to open the .deb file may be insightful as to where it will put it, too.

Then type this from the command-line (substituting your path to pub if it's not like mine); this will add pub to your path:

sudo update-alternatives --install /usr/bin/pub pub /usr/lib/dart/bin/pub 0 

You may need to check first to see if pub is assigned to something else already (it sounds like you already know that it's not, but it's good to know how to do this for the future, including if you want to change which one is assigned at a particular time):

update-alternatives --config pub 

That will let you see what typing pub will run, what alternatives are currently configured for that, and allow you to change which program (of the alternatives) will run when you type pub. If it is assigned to something else, the 0 at the end of the first command I mentioned might need to be changed to a different number.

Note: There are other programs besides pub in the same directory that you might want to add to your path.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!