I don't need this `windows_x86_64_msvc` crate on my computer anymore, how to delete it?

I have this crate: windows_x86_64_msvc v0.48.5 installed.
I would like to delete it from my application.
Which cargo command should i use??
Thanks
Murray

What do you mean by "installed"? If it's a dependency of your project, you can simply delete the corresponding line from Cargo.toml.

cargo remove windows_x86_64_msvc

It's a weird crate isn't it? No src code, just an opaque lib generated... Somehow. Absolutely no docs either!

https://crates.io/crates/windows_x86_64_msvc

I assume it's some clever part of how the windows API rust bindings work somehow. Does anyone understand it?

I think all the crate does is expose the windows.0.52.0.lib static library to the linker.

1 Like

To be precise windows.0.52.0.lib is an import library, which tells the linker in which DLL it can find the symbols used by the window and windows-sys crates. While the Windows SDK ships with import libraries for all these DLLs too, the end goal is to be able to build Windows executables without needing the Windows SDK at all.

The windows-targets crate does have a basic readme however. This crate depends on the right windows_ crate for the target you are compiling for.

6 Likes

Run

cargo tree --target all -i windows_x86_64_msvc

To see which of your dependencies require it, and then remove all of these dependencies from your project.

Keep in mind that having it in the dependency tree doesn't mean it will be used, because dependencies can be optional and platform-specific.

If you want to completely delete it, then it's cached in ~/.cargo/registry.

3 Likes

I ran your command and got this output:

I was not able to find any dependency.
If it's cached in ~/.cargo/registry how do i remove that??

I think taking a step back here may be useful: why do you want to remove it?

3 Likes

That looks like you ran the command on the source code for cargo itself. Unless your goal is to create a modified version of cargo, that won't help anything.

1 Like

I am not pursuing the project any further in which I used this crate, I have deleted the project and would like to remove the crate.

Murray

If you merely don't need to crate anymore, you don't need to delete it. It seems to be a remarkably small crate, so deleting it will probably do nothing. If you suspect malware, please notify the package maintainers.

But if you're dead-set on deleting it, go into C:\Users\YOU\.cargo\registry. Inside, there will be two folders to worry about: src and cache. In both, there will be a folder whose name starts with index.crates.io, followed by random letters and numbers. In both of these index.crates.io folders, do the following: find every file or folder whose name starts with windows_x86_64_msvc, like windows_x86_64_msvc-0.48.5 or windows_x86_64_msvc-0.52.6.crate, and delete it. Don't worry about deleting crates by accident: they will just be re-downloaded when you next use them.

1 Like

I get the error message when I run: cargo install cargo-update

This is the error message I get:

I have searched all of my TOML files trying to find that reference but can't find anything.

Murray

Deleting the crate won't fix that, it will just download the crate again. I'd recommend purging Rust from your system and reinstalling with rustup. Sorry, I misread. That should be unnecessary.

I followed your instructions, rebooted my laptop and reran the command.

I am still getting references to that unused crate.


I believe that these messages are similar to the previous error messages.

I also got this message (from Norton 350):


I have reported this to Norton since I believe that is a false positive.

Murray

Add a directory exclusion to your anti-virus software for all dev directories. Or use a dev drive:

2 Likes

Yeah, antivirus tends to erroneously flag programming stuff. If you want to be sure, you can read the build script to ensure it's not malicious. Otherwise, you can either tell Norton it's safe, or disable it temporarily (I've never used Norton so I don't know the specifics).

I reported it to Norton, suggesting that is a safe file.

Since this file is an exe file, I didn't fare well trying to read it!!

Murray

The exe was compiled from the build script of the crate. If you go into . cargo\registry\src\index.crates.io-____\windows_x86_64_msvc-0.48.5, you can read build.rs. You could also upload it to a file sharing site and share the link, if you want others to review it too.

I searched the suggested folder and found multiple files named build.rs.
Curiously, many of the files had old creation dates, none had a creation date of the last date I ran the script.
I opened each of them and could find no reference to building that exe.
Murray