Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rustc/cargo not recognized as an internal or external command

Tags:

windows

rust

After installing rust on my windows 7 computer, I decided to run a simple hello world program in vscode in a file named main.rc, but on putting the following code in terminal

rustc main.rc

in order to run main.rc, my terminal started giving the following messages:

'rustc' is not recognized as an internal or external command,
operable program or batch file.

I also put the following code in terminal

cargo init

and this time also my terminal gave the following message

'cargo' is not recognized as an internal or external command,
operable program or batch file.

terminal error messages

Then I thought to put all installed rust folders in my C drive where my python folders were also present

C Drive

But no change occurred. Then I thought to put rustc file path to environment variables, but still, all these efforts went in vain.

environment variables screenshot

like image 988
Sam Varghese Avatar asked Jul 15 '26 00:07

Sam Varghese


2 Answers

For me, instructions such as rustc main.rs worked in PowerShell and the Command Prompt, but they did not work in Visual Studio Code's Terminal.

Restarting my computer fixed the problem.

like image 182
Gerhard Liebenberg Avatar answered Jul 17 '26 15:07

Gerhard Liebenberg


I went through that in the past using Windows. I didn't have Microsoft C++ Build Tools installed. As you are using Windows

  1. Make sure you have Microsoft C++ Build Tools installed (Download it here)

  2. Download and install RUSTUP-INIT.EXE (Download the 32-BIT here, Download the 64-BIT here). One can also download from here.

For other Rust installation methods, read this page.

One can also use Windows Subsystem for Linux. If that's the case, run the following and follow the instructions.

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

For additional information on how to install, check this link.

Once the installation is complete, you may want to consider using an IDE. Here you'll see comparison of various editor features. At the present time, VS Code and IntelliJ.

If you end up using IntelliJ, you'll want this plugin.


In case you end up having problems with Rust in the future, apart from posting your question on SO with the tag rust you may want to consider the following discussion platforms:

  • Official Discord

  • Official Users Chat

  • Mozilla Matrix Chat

  • Rust Subreddit

like image 31
Gonçalo Peres Avatar answered Jul 17 '26 16:07

Gonçalo Peres



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!