Failed to build archive: permission denied (trying to build cfg-if dependency)

Without knowingly having changed anything, I suddenly can't build cfg-if as a dependency any more.

error: failed to build archive: permission denied

error: aborting due to previous error

error: could not compile `cfg-if`

Caused by:
  process didn't exit successfully: `rustc --crate-name cfg_if --edition=2018 'C:\Users\SpecificProtagonist\.cargo\registry\src\\cfg-if-1.0.0\src\' --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=a3a8205916d21f07 -C extra-filename=-a3a8205916d21f07 --out-dir 'C:\Users\SpecificProtagonist\Documents\workspace\rust\why\target\debug\deps' -L 'dependency=C:\Users\SpecificProtagonist\Documents\workspace\rust\why\target\debug\deps' --cap-lints allow` (exit code: 1)

This error persists on creating a new project with cfg-if as its only dependency and after having deleted %UserProfile%/.cargo/registry. I'm on Windows 7; as far as I can tell all folder permissions are normal (despite using --verbose, I don't know which file exactly was failed to be created).

Edit: I also have the same error with unicode-xid, not that I think it has anything to do with the crate itself.

Does anyone know how to fix this problem?

This was reported on the github repo, and seems to be specific to Windows 7: Compilation of some crates is broken starting with nightly-2021-01-13 · Issue #81051 · rust-lang/rust · GitHub

1 Like

Thanks, that seems to be the issue!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.