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.
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:
- Point your browser to the Rustup download page and click on the RUSTUP-INIT.EXE button to download Rustup.
- Run the RUSTUP-INIT.EXE file. It will open a console window with instructions on how to install Rust.
- The default settings are fine. In the console window, type 1 and press Enter/Return on your keyboard.
- Rust will now download and install to C:\USERS\username\.cargo\bin and add this path to your PATH environment variable.
- 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:
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.
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.
- Point your browser to the IntelliJ IDEA download page .
- It should automatically recognize your operating system, but if it doesn’t you can select it manually.
- Click on the black Download button on the right to download the Community (free) version.
- Run the installer/image.
- 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.
- 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
- In the new window that pops up, in the search bar, type in ‘Rust’.
- In the search results, select the Rust plugin from Jetbrains and click on the Install button.
- It may require other plugins to be installed as well. For these, simply click on Install when prompted.
- 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.
- In the New Project window, select Rust as the project type.
- The default settings should be fine, but make sure that the Project template is a Binary (application).
- Click Next.
- In the next window we can give our project a name, like ‘tutorial_project’.
- 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.
- Go to the Eclipse for Rust download page and click on Download.
- This zip file contains a portable version of Eclipse for Rust so you can simply extract the folder anywhere on your computer.
- Open the folder and double-click eclipse.exe to run it.
- 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.
- Choose Review IDE configuration settings in the Welcome Page.
- A set up wizard will pop up. Choose the right facing arrow in the bottom corner to continue with the Wizard.
- 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.
- In the main menu, go to Window > Preferences.
- In the dialog box, choose Rust from the menu tree on the left.
- If you see the following error message: Rustup and Cargo paths cannot be empty, uncheck the Use default paths checkbox.
- For Rustup, click on the browse button and navigate to C:\Users\your_username\.cargo\bin and choose rustup.exe.
- For Cargo, click on the browse button and navigate to C:\Users\your_username\.cargo\bin and choose cargo.exe.
- Under Use Rustup > Toolchain, choose Stable from the dropdown menu.
- Click on Apply and Close.
Eclipse will set up the RTL toolchain and we will be ready to create a project.
- On the Welcome page, choose Create new Cargo/Rust project.
- 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.
- 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 IDEs 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 Yet .