ninja-build / ninja

a small build system with a focus on speed
https://ninja-build.org/
Apache License 2.0
11.12k stars 1.59k forks source link

Permission denied on windows #1646

Open atsju opened 5 years ago

atsju commented 5 years ago

Ninja 1.8.2 and 1.9.0 reproduced. In a project creating many static libraries with cmake,

[build] FAILED: Common/05_MCU_abstract_layer/libmal_interrupt.a 
[build] cmd.exe /C "cd . && C:\GIT\FW_Toolchain\cmake\bin\cmake.exe -E remove Common\05_MCU_abstract_layer\libmal_interrupt.a && C:\GIT\FW_TOO~1\GNUTOO~1\7-2018~1\bin\ARM-NO~2.EXE qc Common\05_MCU_abstract_layer\libmal_interrupt.a  Common/05_MCU_abstract_layer/CMakeFiles/mal_interrupt.dir/interrupt/mal_interrupt.c.obj && C:\GIT\FW_TOO~1\GNUTOO~1\7-2018~1\bin\AR17F9~1.EXE Common\05_MCU_abstract_layer\libmal_interrupt.a && cd ."
[build] C:\GIT\FW_TOO~1\GNUTOO~1\7-2018~1\bin\AR17F9~1.EXE: Common\05_MCU_abstract_layer\libmal_interrupt.a: Permission denied

The issue is spurious, not always on same file. When running serial instead parallel, the problem disappear. Also just continuing build when it fails seem to permit finishing the build. I found someone with the same problem (in german) here . I think this could come from parallel (or too fast) access to same files in windows.

atsju commented 5 years ago

I reproduced on several windows 10 environments. I suspected mcafee on-scann access but this is not the case as one of the computer has no mcafee or other specific virus scan installed. Please let me know if I must give some more information

Also in the project, many static libs depend on the same static lib.

nicolasdespres commented 4 years ago

Hi Julien,

I think I have experienced the same problem but with precompiled headers on Window 10. Concurrent access to the same precompiled header resulted in permission denied error. Problem disappeared when running in serial instead of parallel.

Cheers, Nico

On Mon, Sep 9, 2019 at 2:58 PM Julien Staub notifications@github.com wrote:

I reproduced on several windows 10 environments. I suspected mcafee on-scann access but this is not the case as one of the computer has no mcafee or other specific virus scan installed. Please let me know if I must give some more information

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ninja-build/ninja/issues/1646?email_source=notifications&email_token=AAEWBZ6ACAJR5FN4WPH4HFDQIZB6DA5CNFSM4IUIGKN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6HO6HQ#issuecomment-529461022, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEWBZZFY65L4K32CPGOEEDQIZB6DANCNFSM4IUIGKNQ .

-- Nicolas Desprès

atsju commented 4 years ago

Thank you Nicolas. I used the same workaround but this should be fixed. I cannot share my example but do you have a shareable minimal code to reproduce the issue ? This could help to fix it.

nicolasdespres commented 4 years ago

Unfortunately not.

On Thu, Oct 31, 2019 at 9:16 AM Julien Staub notifications@github.com wrote:

I used the same workaround but this should be fixed. I cannot share my example but do you have a shareable minimal code to reproduce the issue ? This could help to fix it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ninja-build/ninja/issues/1646?email_source=notifications&email_token=AAEWBZ5AQEON72HEYOOZBCDQRKH7VA5CNFSM4IUIGKN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECW4RCQ#issuecomment-548259978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEWBZ52FFFIWJNQTUFDDELQRKH7VANCNFSM4IUIGKNQ .

-- Nicolas Desprès

atsju commented 4 years ago

A minimal project to reproduce the bug can be found in this repository. The project has mainly empty file but many diamond dependencies between static libraries. I build on windows 10 with arm-none-eabi-gcc 7-2018-q2 on VScode. The project may need to build several times to reproduce the issue. Please let me know if you can reproduce and if you need more information.

kromancer commented 4 years ago

Maybe this is relevant, it might not be a ninja issue afterall: https://bugs.launchpad.net/gcc-arm-embedded/+bug/1848002

Vox-Ben commented 4 years ago

I have this same problem, Ninja 1.10.0. Any news on a fix? Working around it by disabling threading is painful...

leoatinnovation commented 4 years ago

Hi Vox-Ben,

I'm also facing the same problem. what is the workaround ?

Vox-Ben commented 4 years ago

@leoatinnovation If you pass -j 1 to Ninja it runs only on a single thread (I think the default is three, in normal operation you can set it to whatever you like - ideally probably the same number of (virtual) processor cores that your build machine has). This avoids the bug by not running multiple threads that can conflict, but it reduces the speed. I got about a 50% speed reduction over the three-thread default, if you were otherwise using more threads to start with it'd be worse.

Vox-Ben commented 4 years ago

Just to confirm that this bug is still present in 1.10.1. Any chance you guys could try rebuilding binuitils per @kromancer 's link before you do the next version, to see if that solves the problem?

juangburgos commented 2 years ago

Similar issue here

Error   CMake Error:
  Running

   'C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe' '-C' 'C:/Users/admin/Desktop/REPOS/libuv.git/out/build/x64-Debug' '-t' 'restat' 'build.ninja'

  failed with:

   ninja: error: failed recompaction: Permission denied   C:\Users\admin\Desktop\REPOS\libuv.git\   ninja   
ocroquette commented 2 years ago

Similar issue here, using Ninja 1.10.2:

CMake Error: Running '.../ninja.exe' '-C' '... '-t' 'recompact'

  failed with:

   ninja: error: failed recompaction: Permission denied
jonesmz commented 2 years ago

No one is going to fix this, who isn't experiencing the problem themselves.

If someone who is having this issue has the skills to create a pull request to do whatever it is Ninja needs to do to work around this bug in Windows's filesystem layer, that would probably be the better strategy.

The maintainers for this project does prefer that people discuss the design of a pull request prior to opening one, and get the OK to open the pull request from them though, so try to discuss what a solution would look like here in this issue prior to making the PR. (See discussion here for the issue/pr plan https://github.com/ninja-build/ninja/pull/2154#issuecomment-1223233807)

Ashafix commented 1 year ago

Bit late to the party but in my case directory names with spaces caused the issue. I've created a symlink mklink /D "c:\ProgramFiles\NVIDIA_GPU_Computing_Toolkit" "c:\Program Files\NVIDIA GPU Computing Toolkit" and the the environment variables CUDA_HOME and CUDA_PATH to the new directory set CUDA_PATH="c:\ProgramFiles\NVIDIA_GPU_Computing_Toolkit\CUDA\v11.8" set CUDA_HOME=%CUDA_PATH%

Frisk4973 commented 5 months ago

help C:\aseprite\build>C:\users\rgb_m\ninja-win\ninja.exe -f C:\aseprite ninja: error: loading 'C:\aseprite': Access is denied. if you're wondering why i kept the username in the path when making this comment, it's because it's not my actual name (obviously)

clshortfuse commented 4 weeks ago

I had to delete my build folder. No idea why, but fixed my issue.