I have a working Rust setup on Windows 11 and can run the hello world program with the PowerShell command line:
PS C:UsersMichaelDesktoptrying-cargo%TEST> cargo new helloworld
Creating binary (application) `helloworld` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
PS C:UsersMichaelDesktoptrying-cargo%TEST> cd .helloworld
PS C:UsersMichaelDesktoptrying-cargo%TESThelloworld> cargo run
Compiling helloworld v0.1.0 (C:UsersMichaelDesktoptrying-cargo%TESThelloworld)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.19s
Running `targetdebughelloworld.exe`
Hello, world!
But as soon as I try to add a dependency, say cargo add regex
, then cargo run
again, I get an error
PS C:UsersMichaelDesktoptrying-cargo%TESThelloworld> cargo run
Compiling memchr v2.7.4
...
error: failed to build archive: no such file or directory
I’ve tried this with several crates from crates.io and they all lead to the same error. What does this error message mean and how can I fix it?
So it turns out the issue was having a folder named %TEST in the file path. After removing the %
character/symbol and trying again, things worked fine.
While looking into this, I learned about verbose output for cargo, and after examining the output of cargo -v -v run
, I guess the %
is being interpreted as a kind of variable substitution, as that’s how it’s done in batch files. I wasn’t able to find any documentation about how this might affect PowerShell though, and still don’t really know if this is a script bug in calling rustc or an argument parsing bug in rustc itself.
1