aum Posted July 23, 2021 Share Posted July 23, 2021 Conda is an open-source package management system and environment management system for installing multiple versions of software packages and their dependencies. It is mainly developed for Python and not tied to any specific programming language. Conda allows you to install many programming languages in multiple different environments. In this post, we will show you how to create Rust virtual environments using Conda in Linux. Prerequisites A server running Ubuntu 20.04. A root password is configured on the server. Install Required Dependencies First, update your system packages to the latest version with the following command: apt-get update -y Once all the packages are updated, install other required packages with the following command: apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 -y Once all the packages are installed, you can proceed to the next step. Install Anaconda First, download the Anaconda installation script with the following command: wget https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh Once the script is downloaded, run the downloaded script with the following command: bash Anaconda3-2021.05-Linux-x86_64.sh You will be asked to type yes or no as shown below: Please answer 'yes' or 'no':' >>> yes Anaconda3 will now be installed into this location: /root/anaconda3 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below Do you wish the installer to initialize Anaconda3 by running conda init? [yes|no] Once the Anaconda has been installed, activate the Conda environment with the following command: source ~/.bashrc Create Rust Virtual Environments Using Conda The Rust toolchain installer provides a rustup utility to install Rust on Linux. However, you can also use the Conda package manager to install and manage the Rust programming language. To create a new Rust environment, run the following command: conda create -c conda-forge -n rustenv rust Once the process has been finished, you should get the following output: # # To activate this environment, use # # $ conda activate rustenv # # To deactivate an active environment, use # # $ conda deactivate Next, verify the Rust environment with the following command: conda info --envs You should see the following output: # conda environments: # base * /root/anaconda3 rustenv /root/anaconda3/envs/rustenv Next, you will need to activate the Rust environment. You can activate it using the following command: conda activate rustenv You should get the following output: (rustenv) root@ubuntu2004:~# Now, verify the Rust version with the following command: rustc --version You should see the following output: rustc 1.53.0 (53cb7b09b 2021-06-17) You can also check the Corgo package version with the following command: cargo --version You should see the following output: cargo 1.53.0 (4369396ce 2021-04-27) Add Cargo Environment to your SYstem Path: Next, you will need to add a Cargo environment to your system path to make it permanent. To do so, edit the .bashrc file with the following command: nano ~/.bashrc Add the following lines: export PATH=/root/.cargo/bin:$PATH Save and close the file then activate the environment with the following command: source ~/.bashrc Deactivate and Delete Rust Environment To deactivate the Rust environment, run the following command: conda deactivate Next, delete the Rust environment permanently from your system using the following command: conda env remove -n rustenv Conclusion Congratulations! you have successfully created a Rust environment using Conda. You can now start creating your first project using Rust. Source Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.