Skip to content

Latest commit

 

History

History
291 lines (177 loc) · 9.61 KB

File metadata and controls

291 lines (177 loc) · 9.61 KB

Install Rust and Visual Studio Code

The following instructions are for setting up a student machine for the course. There are instructions for Linux, macOS, Windows, and Windows WSL 2. Also, all students will need to create a GitHub account.

These instructions provide a minimal setup for the course. During the course other software and code libraries will be installed. Students will need local admin and network access on their machines.

These instructions will ensure you have Rust installed, Visual Studio Code installed, a Rust debugging environment, and the ability to install crates with Cargo.

Complete the setup appropriate for your machine. We will be using a tool named Valgrind in the class. Valgrind does not work on Windows. If you are using Windows, you will need to use Windows Subsystem for Linux 2 (WSL 2) to run Valgrind.

During the course additional Rust tools and crates will be installed. Also, depending on your operating system additional software may be required. Students will need local admin and network access on their machines.

Also, for courses which include bare metal programming, each student will need a Microbit V2. The Microbit V2 is a small microcontroller board that can be programmed in Rust. The Microbit V2 can be purchased from various online retailers.

Before purchasing, verify if your employer or the trainer will be providing the device for you. The link above is NOT an Amazon affiliate link.

All Students

  1. To access the courseware for the class, all students will need to create a GitHub account. If you do not already have a GitHub account, please create one at https://www.github.com. Please know your GitHub username and password on the first day of class.

    Note: GitHub Enterprise accounts will not work. You must have a personal, public GitHub account.

Linux

  1. Install software development packages.

    sudo apt install -y build-essential cmake pkg-config
  2. Open a terminal window, and run the following command to install Rust.

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  3. Close all terminal windows.

  4. Open a new terminal window, and create a new Rust project in the home folder.

    cargo new test_config
  5. Change to the new project folder.

    cd test_config
  6. Build the project.

    cargo build
  7. Run the project.

    cargo run
  8. Verify you can install crates with Cargo. The installation should proceed without error.

    cargo add serde
  9. Download the appropriate Visual Studio Code installer for your Linux distribution: https://code.visualstudio.com/download

  10. Install Visual Studio Code on Linux.

  11. Open Visual Studio Code.

  12. Using the main menu, under the File menu, select Open Folder... and open the test_config folder.

  13. On the left-hand side of Visual Studio Code, there is a vertical Activity Bar with icons. Click on the squares icon to open the Extensions view.

  14. At the top of the Extensions view you will see a search box. In the extension search box, search for the rust-lang.rust-analyzer and install it. Then, search for the vadimcn.vscode-lldb extension and install it.

  15. Once installed, you should be able to click Run and Debug in Visual Studio Code above the main function of the test_config project.

macOS

  1. Open a terminal window, and install Rust.

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. Close all terminal windows.

  3. Open a new terminal window, and create a new Rust project in the home folder.

    cargo new test_config
  4. Change to the new project folder.

    cd test_config
  5. Build the project.

    cargo build
  6. Run the project.

    cargo run
  7. Verify you can install crates with Cargo. The installation should proceed without error.

    cargo add serde
  8. Download the Visual Studio Code installer: https://code.visualstudio.com/sha/download?build=stable&os=darwin-universal

  9. Install Visual Studio Code on macOS.

  10. Open Visual Studio Code.

  11. Using the main menu, under the File menu, select Open Folder... and open the test_config folder.

  12. On the left-hand side of Visual Studio Code, there is a vertical Activity Bar with icons. Click on the squares icon to open the Extensions view.

  13. At the top of the Extensions view you will see a search box. In the extension search box, search for the rust-lang.rust-analyzer and install it. Then, search for the vadimcn.vscode-lldb extension and install it.

  14. Once installed, you should be able to click Run and Debug in Visual Studio Code above the main function of the test_config project.

Windows

  1. Download the Rust installer: https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe.

  2. Run the rustup-init.exe file.

  3. It may prompt you to install the Microsoft C++ build tools. If so, please install then proceded with the Rust installation.

  4. Close all terminal windows, and open a new PowerShell or Windows Command Prompt terminal window, and create a new Rust project in the home folder.

    cargo new test_config
  5. Change to the new project folder.

    cd test_config
  6. Build the project.

    cargo build
  7. Run the project.

    cargo run
  8. Verify you can install crates with Cargo. The installation should proceed without error.

    cargo add serde
  9. Download the appropriate Visual Studio Code installer: https://code.visualstudio.com/download

  10. Install Visual Studio Code on Windows.

  11. Open Visual Studio Code.

  12. Using the main menu, under the File menu, select Open Folder... and open the test_config folder.

  13. On the left-hand side of Visual Studio Code, there is a vertical Activity Bar with icons. Click on the squares icon to open the Extensions view.

  14. At the top of the Extensions view you will see a search box. In the extension search box, search for the rust-lang.rust-analyzer and install it. Then, search for the vadimcn.vscode-lldb extension and install it.

  15. Once installed, you should be able to click Run and Debug in Visual Studio Code above the main function of the test_config project.

Windows WSL 2

  1. Ensure two optional features for Windows are installed.

    • Virtual Machine Platform
    • Windows Subsystem for Linux

    To verify and install them, run the following command from a terminal window.

    optionalfeatures

    If features are installed, you will need to reboot.

  2. Install and Configure WSL 2: https://docs.microsoft.com/en-us/windows/wsl/install. Open a Windows Powershell terminal, and run the following command.

    wsl --install

    Your computer may need to be rebooted after installation is complete.

  3. Open a Windows Powershell terminal, and verify WSL version and Ubuntu are configured properly.

    wsl -l -v
  4. Open a Windows WSL 2 Ubuntu terminal window, and install Build Essentail packages.

    sudo apt install build-essential
  5. Install Rust.

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  6. Close all terminal windows.

  7. Open a new WSL 2 terminal window, and create a new Rust project in the home folder.

    cargo new test_config
  8. Change to the new project folder.

    cd test_config
  9. Build the project.

    cargo build
  10. Run the project.

    cargo run
  11. Verify you can install crates with Cargo. The installation should proceed without error.

    cargo add serde
  12. On Windows (not within WSL), download the appropriate Visual Studio Code installer: https://code.visualstudio.com/download

  13. Install Visual Studio Code on Windows.

  14. Open Visual Studio Code.

  15. On the left-hand side of Visual Studio Code, there is a vertical Activity Bar with icons. Click on the squares icon to open the Extensions view.

  16. At the top of the Extensions view you will see a search box. In the extension search box, search for the extension with id ms-vscode-remote.remote-wsl. Click the Install button.

  17. Open Visual Studio Code. Open the command palette by pressing Ctrl+Shift+P. In the command palette, type WSL: Connect to WSL, and press enter.

  18. Open the command palette by pressing Ctrl+Shift+P. In the command palette, type WSL: Open Folder and select the option to open the folder in WSL.

  19. Select the test_config folder in the WSL environment. If prompted, trust the folder.

  20. Review the locally installed extensions, and click the Install in WSL: Ubuntu blue button for the following extensions.

    • rust-lang.rust-analyzer
    • vadimcn.vscode-lldb
    • tamasfe.even-better-toml
  21. Once installed, you should be able to click Run and Debug in Visual Studio Code above the main function of the test_config project.