1

I am getting the following error on Windows:

Cargo, the Rust package manager, is not installed or is not on PATH.
remote: This package requires Rust and Cargo to compile extensions.

I've installed Rust and cargo is in the path, but the problem persists. Does anybody know why this is happening?

Error message is the same as in this post.

kmdreko
  • 42,554
  • 6
  • 57
  • 106
fmtcs
  • 87
  • 1
  • 8

3 Answers3

2

Heroku's stack runs on Ubuntu. Cargo is required by pywinpty but that's a library required for communicating with Windows processes. You may need it for your local environment but you don't need it for Heroku. You should try removing pywinpty from your requirements.txt when you deploy to Heroku.

scign
  • 812
  • 5
  • 15
1

If you want a temporary solution

Open a command line prompt (cmd) and execute

path

that will show you the actual, current path. Inspect it to see whether the necessary directories are really absent. If they are, execute

path=%path%;directory you want to add;other directory you want to add

The path will be available in the command prompt for as long as it's open. If they are present, reboot the computer, the addition to the path may have been delayed after installation.

The permanent solution

For Win10 but I guess instructions are not very different for other flavors. Open System properties, find Environment Variables. In the dialog that pops up you will see System Variables, among which you will see Path. Select it, click edit and add the directories you need via the New button. Close all popup boxes and reboot (always a good idea when Windows is stubborn ;-) )

fvu
  • 32,488
  • 6
  • 61
  • 79
  • Thanks for the answer, I added .cargo\bin to PATH, restarted, and still getting the same message. Not sure what's going on – fmtcs May 12 '22 at 10:25
  • Are you sure it can find the rust compiler somewhere in the path? If you know the name of its executable, you can easily test whether it can be found by entering the name in a command prompt, as I explained. – fvu May 12 '22 at 10:45
  • when I type any of the file names from .cargo\bin (e.g. rustc which is the compiler) it shows up with a bunch of information for the file. So I assume that it can access everything? – fmtcs May 12 '22 at 11:13
  • to be clear this is happening when I'm trying to do a git push to a Heroku app. It installs all the dependencies and there is an error with installing Pywinpty, then I get "Preparing metadata (pyproject.toml): finished with status 'error'" which leads into "Preparing metadata (pyproject.toml) did not run successfully. Checking for rust toolchain..." and then my error. – fmtcs May 12 '22 at 11:17
  • Seems like a pretty common problem. Try pasting ```Cargo, the Rust package manager, is not installed or is not on PATH``` in Google, there are a number of interesting discussions that will come up. I saw several solutions come up, ranging from reinstalling till it works (???) to upgrading pip or switching python from 32 to 64 bits. – fvu May 12 '22 at 11:17
  • will have a look, thanks! – fmtcs May 12 '22 at 11:19
  • 1
    I also added the rust0cargo tag to your question to attract more knowledgeable people! – fvu May 12 '22 at 11:20
0

To add Cargo path add the following line: "export PATH=$PATH:~/.cargo/bin/" at the end of the file, to edit execute:

nano ~/.bashrc

Here is the line you need to add at the bottom:

export PATH=$PATH:~/.cargo/bin/

After that exit, and re open, type

cargo

If you see the help "Rust package manager" section, everything worked correctly.

Here you have a screenshot with the correct result: Screenshot of Rust package manager

(tip: if you don't know how to install rust, execute:

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

then press option 1). After that, read again this answer to add the path!