Saturday, 4 July 2015

Rust: RustDT IDE on Linux with Eclipse Mars

This is a quick guide to setting up an IDE for Rust using RustDT. Familiarity with Linux and root access is assumed. Modify commands to suit your preferences, paths, and/or the latest versions.

Stack:

  • Host: Debian 8.1.0 amd64 lxde (debian-live-8.1.0-amd64-lxde-desktop.iso)
  • Eclipse: Mars; JDK 8 runtime
  • Rust: 1.1.0

Documentation:

Files Used

Obtain these files from the links above.

rust-1.1.0-x86_64-unknown-linux-gnu.tar.gz
rustc-1.1.0-src.tar.gz
eclipse-jee-mars-R-linux-gtk-x86_64.tar.gz
jdk-8u45-linux-x64.tar.gz

Install Tools

Extract tools into (/home/user/tools) user space:

$ mkdir ~/tools
$ tar xzf ~/Downloads/eclipse-jee-mars-R-linux-gtk-x86_64.tar.gz -C ~/tools/
$ tar xzf ~/Downloads/jdk-8u45-linux-x64.tar.gz -C ~/tools/
$ tar xzf ~/Downloads/rust-1.1.0-x86_64-unknown-linux-gnu.tar.gz -C ~/tools/
$ tar xzf ~/Downloads/rustc-1.1.0-src.tar.gz -C ~/tools/
Install Rust

This provides the Rust compiler and the Cargo build tool.

$ su
Password: 
# cd /home/user/tools/rust-1.1.0-x86_64-unknown-linux-gnu/
# ./install.sh
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'
install: installing component 'cargo'
install: installing component 'rust-docs'

    Rust is ready to roll.

# exit
Edit the PATH

Set up the user profile by editing ~/.xsessionrc and appending:

export PATH="$HOME/tools/jdk1.8.0_45/bin:$HOME/tools/eclipse:$PATH"

Reinitialize the console environment or reboot.

Note: LXDE ignores .profile.

Build Racer

Install git:

$ su
Password: 
# apt-get install git
The following NEW packages will be installed:
  git git-man liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 23 not upgraded.
Need to get 4,913 kB of archives.
After this operation, 23.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
# exit

Fetch and build Racer for autocompletion:

$ cd ~/tools/
$ git clone https://github.com/phildawes/racer.git
Cloning into 'racer'...
remote: Counting objects: 2628, done.
remote: Compressing objects: 100% (39/39), done.
remote: Total 2628 (delta 13), reused 0 (delta 0), pack-reused 2586
Receiving objects: 100% (2628/2628), 4.28 MiB | 496.00 KiB/s, done.
Resolving deltas: 100% (1606/1606), done.
Checking connectivity... done.
$ cd racer/
$ cargo build --release
    Updating registry `https://github.com/rust-lang/crates.io-index`
...
   Compiling racer v0.0.1
Install RustDT

Install the RustDT plugin into Eclipse:

$ ~/tools/eclipse/eclipse -nosplash -application org.eclipse.equinox.p2.director -repository https://rustdt.github.io/releases/ -installIU com.github.rustdt.feature.group
org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was activated before the state location was initialized.  Will retry after the state location is initialized.
Installing com.github.rustdt.feature.group 0.2.1.v201506111418.
Operation completed in 121957 ms.

Alternatively, use the GUI to install RustDT using the https://rustdt.github.io/releases/ update site.

Configure the Eclipse Workspace

Start Eclipse:

~/tools/eclipse/eclipse
  1. Pick a workspace location
  2. Select Window > Preferences
  3. Filter on Rust
  4. Set the tool paths:
    • Rust installation
      • Directory: /usr/local
      • Rust 'src' Directory: /home/user/tools/rustc-1.1.0/src
    • Racer installation
      • Executable: /home/user/rs/racer/target/release/racer

Rust projects can be created via the File > New > Project... menu.

No comments:

Post a Comment

All comments are moderated