Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cargo path setup for rust-racer

I just installed racer using cargo. After installing it say this:

Installing /home/karthik/.cargo/bin/racer
warning: be sure to add `/home/karthik/.cargo/bin` to your PATH to be able to run the installed binaries

How do I do this? Googling didn't help. Also, Should I be setting a PATH variable for cargo bin as well?

Edit: OS is Ubuntu 14.04 and I have super user access

like image 490
KDN Avatar asked Jun 22 '16 11:06

KDN


People also ask

How do I set racer's path from command line?

In command line mode you just have to type export PATH=$PATH:/home/karthik/.cargo/bin and hit Enter. Then type your command to run your program Ok, I've done that, now how do I set Racer's path? I've cloned rust's src code and set the Rust src path Ok, I have a new problem. For racer I did export PATH=$PATH:/home/karthik/.cargo/bin/racer.

Should I install rust or cargo?

As a regular user, you would be using Cargo for installing Rust based applications. As a programmer, you’ll need Cargo for getting other Rust packages or create your own. Since Cargo includes rustc, I would advise installing it so that all required packages are installed in one go.

Can I use rust racer with multiple release channels?

Rustup will keep the sources in sync with the toolchain if you run rustup update. If you want to use racer with multiple release channels (Rust has 3 release channels: stable, beta and nightly ), you have to also download Rust source code for each release channel you install.

Where can I export rust_SRC_path?

The nfor the rust src path I did export RUST_SRC_PATH=/usr/local/src/rust/src. This works and I can use racer (and it works in vim with YouCompleteMe). But it doesn't work in any other terminal instance and if I close the terminal I did it in, it still doesn't work anywhere


2 Answers

You have to add the cargo bin path to your PATH variable and set the RUST_SRC_PATH in .profile or .bash_profile.

Related unix.stackechange question

like image 196
JDemler Avatar answered Sep 22 '22 03:09

JDemler


There are two steps:

(1) Add the Cargo bin to your PATH variable. You can run $ whereis cargo to find the bin path, and then do $ sudo -H gedit /etc/environment where you can add that new path section to your current PATH variable. You will need to save and close the file (and you can ignore the error message in the terminal during the saving portion) in order for it to take effect.

(2) Run $ rustup component add rust-src to download the necessary Rust source files for you.

At this point Racer should work properly.

This is based on the answer here.

like image 42
MLev Avatar answered Sep 22 '22 03:09

MLev