-2

I am trying to use bevy game engine with rust on windows. I have x86_64-mingw installed on my machine. I have setup the rust tool chain default to x86_64-pc-windows-gnu. I put bevy = "0.4.0" under my dependencies in the Cargo.toml.
I tried cargo build and I get the following error

error: failed to run custom build command for `syn v1.0.63`

Caused by:
  could not execute process `C:\Users\USERNAME\Projects\rust-game\target\debug\build\syn-a158346a8e8b6be7\build-script-build` (never executed)

Caused by:
  Access is denied. (os error 5)
warning: build failed, waiting for other jobs to finish...
error: build failed

When I tried to compile in administrator mode syn compiled but another lib was giving error

   Compiling proc-macro2 v1.0.24
   Compiling syn v1.0.63
   Compiling serde_derive v1.0.124
   Compiling serde v1.0.124
error: failed to run custom build command for `proc-macro2 v1.0.24`

Caused by:
  could not execute process `C:\Users\USERNAME\Projects\rust-game\target\debug\build\proc-macro2-a1d2a8cf734884f9\build-script-build` (never exe
cuted)

Caused by:
  Access is denied. (os error 5)
warning: build failed, waiting for other jobs to finish...
error: build failed

Edit: My Antivirus was preventing it, and denying it access, so just turning my AV for sometime worked!

NrdyBhu1
  • 375
  • 4
  • 14
  • Have you tried using a console with admin privileges? The error is `Access is denied` which usually occurs when the OS denies access to some file/folder or resource. – PauMAVA Mar 12 '21 at 09:53
  • @PauMAVA, yes as i mentioned in the details also `When I tried to compile in administrator mode syn compiled but another lib was giving error`, please read completely – NrdyBhu1 Mar 12 '21 at 10:40
  • Yes sorry, my brain skipped that part somehow. I've posted a fix that has worked for me. – PauMAVA Mar 12 '21 at 15:04

1 Answers1

3

I've tried compiling a project that uses bevy = "0.4.0" and was able to build with the stable-x86_64-pc-windows-msvc toolchain but not with stable-x86_64-pc-windows-gnu.

In my case, bevy-glsl-to-spirv is the crate that failed to build. On the bevy book is specified that you must have VS build tools 2019 installed. They do not explicitly say that you must use the msvc toolchain but as they require you to install VS build tools 2019 I guess you must compile the code using stable-x86_64-pc-windows-msvc.

You can download VS build tools 2019 here.

Also make sure that you install the stable-x86_64-pc-windows-msvc toolchain:

rustup toolchain install stable-x86_64-pc-windows-msvc

Set this toolchain as the default toolchain.

rustup default stable-x86_64-pc-windows-msvc

Finally, make sure the toolchain has been installed and set as the default toolchain:

rustup toolchain list

You should see:

stable-x86_64-pc-windows-gnu
stable-x86_64-pc-windows-msvc (default)

Try to cargo build and it should work like a charm.

PauMAVA
  • 1,163
  • 14
  • 23
  • 1
    yes, i did do that later, but the problem was that my anti-virus was blocking cargo, thanks also. I referred [here](https://github.com/rust-lang/cargo/issues/2306) – NrdyBhu1 Mar 15 '21 at 03:12
  • Do you have Vulkan drivers installed? – Jack Apr 09 '21 at 05:01