Development Environment Setup

In this Rust tutorial we learn set up a development environment for Rust step-by-step with the Rust compiler and portable Eclipse IDE with Corrosion plugin or the free version of IntelliJ IDEA with the Rust plugin.

We also set up our first Rust project and take a look at the Eclipse / IDEA workspaces we'll be working in.

Here's a table of contents of what you'll learn in this lesson:
(click on a link to skip to its section)

Let's jump right in.

Rust Development Environment

Before we can start learning how to code and create programs with Rust, we need a development environment.

A Rust development environment consists of the following:

  • The Rust compiler
  • A text editor or IDE (integrated development environment)

We use and recommend the IntelliJ IDEA Community (free version) IDE for Rust. We cover installing it, adding the free Rust plugin and quickly explore its workspace. We also cover an alternative portable version of the Eclipse IDE.

If you want to use a different IDE, we provide a list of alternatives for Rust at the end of this tutorial.

Rust provides us with an easy console-based tool to install Rust and manage its versions and associated tools. This tool is called Rustup.

How to install Rust on Windows

Please follow the instructions below to install Rustup on Windows:

  1. Point your browser to the Rustup download pageOpens up in a new page and click on the RUSTUP-INIT.EXE button to download Rustup.
  2. Run the RUSTUP-INIT.EXE file. It will open a console window with instructions on how to install Rust.
  3. The default settings are fine. In the console window, type 1 and press Enter/Return on your keyboard.
  4. Rust will now download and install to C:\USERS\username\.cargo\bin and add this path to your PATH environment variable.
  5. Once the installation has been completed, press Enter/Return on your keyboard to close the console window.

How to install Rust on Mac OS X/Linux/BSD/Unix

Please follow the instructions below to install Rust (via Rustup) on Mac OS x/Linux/BSD/Unix:

Open up your terminal and type in this command:

Example:
 curl https://sh.rustup.rs -sSf | sh

This will download the Rustup installer which will, in turn, fetch everything you need like the compiler and package manager.

To verify that everything is installed, run the following command in your terminal.

Example:
 cargo version

Any version number means that everything was installed.

How to set up IntelliJ IDEA for Rust

We recommend IntelliJ IDEA with its Rust plugin for Rust development.

  1. Point your browser to the IntelliJ IDEA download pageOpens up in a new page .
  2. It should automatically recognize your operating system, but if it doesn’t you can select it manually.
  3. Click on the black Download button on the right to download the Community (free) version.
  4. Run the installer/image.
  5. Check the box next to add launchers dir to the PATH

Now that IntelliJ IDEA has been installed, we can add the Rust plugin. Launch the program now.

If this is your first time starting up the IDE, you will see a setup wizard. Choose the theme you want (we recommend the dark theme) and skip the rest of the setup wizard.

  1. On the bottom right of the Welcome screen, open the Configure menu and select Plugins. The plugin setup can also be accessed by going to File > Settings > Plugins
  2. In the new window that pops up, in the search bar, type in ‘Rust’.
  3. In the search results, select the Rust plugin from Jetbrains and click on the Install button.
  4. It may require other plugins to be installed as well. For these, simply click on Install when prompted.
  5. Once the installation has finished, click on the Restart IDE button.

When the IDE has restarted, click on + Create New Project in the Welcome screen.

  1. In the New Project window, select Rust as the project type.
  2. The default settings should be fine, but make sure that the Project template is a Binary (application).
  3. Click Next.
  4. In the next window we can give our project a name, like ‘tutorial_project’.
  5. Click Finish.

That’s it, you’re now ready to write Rust apps.

The IntelliJ IDEA workspace

Before we start writing apps in Rust, let’s quickly explore the IntelliJ IDEA workspace.

The Project Explorer:

On the left-hand side of the screen we have the Project Explorer which contains a tree view of the files in our project.

By default, the project will be collapsed. Click on the arrow next to ‘tutorial_project’ to expand the tree view of the project.

Next, expand the subfolder called src. Inside this folder will be a file called main.rs , double click it to open it up in the Code Editor.

The Code Editor:

On the right-hand side of the screen, we have the Code Editor. This window is where we edit the source code for our Rust applications.

The Console Window:

Below the Code Editor is the Console Window where all our console message will be displayed.

If your Console window isn’t showing, don’t worry, it will pop-up once we compile our first program in the next lesson.

That’s it, that’s all we need to get started programming with Rust. You can skip directly to the next tutorial lesson where we will write our First Rust Application .

How to set up Eclipse for Rust

Now that we have Rust installed, we can download the Eclipse IDE for Rust Developers.

  1. Go to the Eclipse for Rust download pageOpens up in a new page and click on Download.
  2. This zip file contains a portable version of Eclipse for Rust so you can simply extract the folder anywhere on your computer.
  3. Open the folder and double-click eclipse.exe to run it.
  4. A pop-up dialog box will ask you to select a workspace for Eclipse. Choose a directory (or use the default) and click Launch.

Eclipse will need a few more configurations.

Once Eclipse launches, you will see a Welcome page with several options. The Welcome page is also available from the Help menu.

  1. Choose Review IDE configuration settings in the Welcome Page.
  2. A set up wizard will pop up. Choose the right facing arrow in the bottom corner to continue with the Wizard.
  3. On all the following screens, select the green checkmark button until the wizard has finished.

The next step is to ensure our paths are correctly configured.

  1. In the main menu, go to Window > Preferences.
  2. In the dialog box, choose Rust from the menu tree on the left.
  3. If you see the following error message: Rustup and Cargo paths cannot be empty, uncheck the Use default paths checkbox.
  4. For Rustup, click on the browse button and navigate to C:\Users\your_username\.cargo\bin and choose rustup.exe.
  5. For Cargo, click on the browse button and navigate to C:\Users\your_username\.cargo\bin and choose cargo.exe.
  6. Under Use Rustup > Toolchain, choose Stable from the dropdown menu.
  7. Click on Apply and Close.

Eclipse will set up the RTL toolchain and we will be ready to create a project.

  1. On the Welcome page, choose Create new Cargo/Rust project.
  2. In the pop-up dialog box, in the Location field, name the project “tutorial_project”. The Location field should look like this: C:\Users\your_username\Documents\Eclipse\tutorial_project.
  3. Click Finish.

Eclipse will set up a new Rust project where we can write our programs.

The Eclipse Workspace

Now that we’re all set up and ready to start, let’s quickly explore our workspace in Eclipse.

The Project Explorer:

On the left-hand side of the screen we have the Project Explorer which contains a tree view of the files in our project.

Expand the src folder by clicking on the arrow button and double-click on the file called main.rs to open it up in the Code Editor.

The Code Editor:

On the right-hand side of the screen, we have the Code Editor. This window is where we edit the source code for our Rust applications.

The Console Window:

Below the Code Editor is the Console Window where all our console message will be displayed.

If your Console window isn’t showing, don’t worry, it will pop-up once we compile our first program in the next lesson.

That’s it, that’s all we need to get started programming with Rust. You can skip directly to the next tutorial lesson where we will write our First Rust Application .

Alternate IDE’s for Rust Development

You can find a full up-to-date list of editors (with their dependencies) for Rust support at Are We (I)DE YetOpens up in a new page .