cc-rs icon indicating copy to clipboard operation
cc-rs copied to clipboard

Concrete instructions for getting MSVC Clang installed

Open djmattyg007 opened this issue 3 months ago • 6 comments

Is there a set of concrete instructions for getting MSVC Clang installed? I'm not sure if that's the right terminology but I'm honestly not sure. I'm not using cc-rs directly, but rather through another software package (nvim-treesitter). The documentation I'm following is here:

https://docs.rs/cc/latest/cc/#compile-time-requirements

And that's helpful, but it doesn't tell me how to get the requirements installed. I've tried the following:

  • winget install MartinStorsjo.LLVM-MinGW.MSVCRT
  • winget install MSYS2.MSYS2
  • winget install LLVM.LLVM
  • winget install Microsoft.VisualStudio.2022.BuildTools
    • Followed by running the build tools and ensuring the Clang components are installed (see screenshot below)

I've tried running the software in a regular Powershell prompt, as well as the Developer Powershell for VS 2022 prompt, and no matter what I try, I still get errors about cl.exe not being in my PATH. I don't know what else to do or try. Any pointers would be appreciated.

Image

djmattyg007 avatar Sep 30 '25 00:09 djmattyg007

Maybe you could try scroop as well?

cc @ChrisDenton since I'm not familiar with package installion windows

NobodyXu avatar Sep 30 '25 08:09 NobodyXu

The LLVM version is called clang-cl.exe. If it errors with cl.exe then it suggests that it's looking for (and can't find) the regular msvc tools.

ChrisDenton avatar Sep 30 '25 08:09 ChrisDenton

Maybe you could try scroop as well?

I don't really want to start using scoop. I don't have anything against it, but I'm already using both winget and chocolatey, and I don't really want to introduce a third package manager just for this. If there's literally no other way to deal with this, then I'll give it a try, but I'd want to know first (with some degree of certainty) that using winget plus the Visual Studio Build Tools is definitely not going to work.

The LLVM version is called clang-cl.exe. If it errors with cl.exe then it suggests that it's looking for (and can't find) the regular msvc tools.

How can I diagnose why it's unable to find the regular MSVC tools?

djmattyg007 avatar Sep 30 '25 23:09 djmattyg007

How can I diagnose why it's unable to find the regular MSVC tools?

Try cargo build -v, you could also set env var CC_ENABLE_DEBUG_OUTPUT

NobodyXu avatar Oct 01 '25 10:10 NobodyXu

I don't have a rust development toolchain installed, because I'm not intending to contribute to cc-rs. I'm just a downstream consumer of software that utilises cc-rs. I'll see if I can get the debug output by setting that environment variable, but I'm not sure how it will be presented given how cc-rs is being used in nvim-treesitter.

djmattyg007 avatar Oct 02 '25 00:10 djmattyg007

I'll see if I can get the debug output by setting that environment variable, but I'm not sure how it will be presented given how cc-rs is being used in nvim-treesitter.

Aha you don't need cargo.

If nvim-treesitter is using cc to compile stuff at runtime, just enable the env var I mentioned, it should provide some output.

NobodyXu avatar Oct 02 '25 09:10 NobodyXu