Search Unity

UnauthorizedAccessException Windows Build Error

Discussion in 'Editor & General Support' started by TescoEiles, Jan 23, 2022.

  1. TescoEiles

    TescoEiles

    Joined:
    Mar 30, 2021
    Posts:
    1
    Hi all.

    This is my first time building a project of mine, in Unity, and thus I am a little confused by this build error that has appeared whilst building the project:
    Code (CSharp):
    1.  
    2. BuildFailedException: Burst compiler (1.6.0) failed running
    3.  
    4. stdout:
    5. Compiled 1 library, containing 8 methods, in 2687ms using 8 threads: C:\Users\User\Desktop\UnityFolder\European Theater Night EX\Temp\StagingArea\Data\Plugins\x86\lib_burst_generated.dll,C:\Users\User\Desktop\UnityFolder\European Theater Night EX\Temp\StagingArea\Data\Plugins\x86\lib_burst_generated.pdb
    6. An unexpected exception occurred:
    7. stderr:
    8. System.UnauthorizedAccessException: Access to the path 'C:\Users\User\Desktop\UnityFolder\European Theater Night EX\Temp\StagingArea\Data\Plugins\x86\lib_burst_generated.txt' is denied.
    9.    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    10.    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
    11.    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
    12.    at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
    13.    at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
    14.    at System.IO.StreamWriter..ctor(String path)
    15.    at Burst.Bcl.Program.BuildTheThing(BclOptions options, Stopwatch& individualTimer)
    16.    at Burst.Bcl.Program.Main(String[] args)
    17.  
    18. Unity.Burst.Editor.BurstAotCompiler+BclRunner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at Library/PackageCache/com.unity.burst@1.6.0/Editor/BurstAotCompiler.cs:1378)
    19. Unity.Burst.Editor.BurstAotCompiler+BclRunner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at Library/PackageCache/com.unity.burst@1.6.0/Editor/BurstAotCompiler.cs:1275)
    20. Unity.Burst.Editor.BurstAotCompiler+BclRunner.RunManagedProgram (System.String exe, System.String args, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at Library/PackageCache/com.unity.burst@1.6.0/Editor/BurstAotCompiler.cs:1250)
    21. Unity.Burst.Editor.BurstAotCompiler.OnPostBuildPlayerScriptDLLsImpl (UnityEditor.Build.Reporting.BuildReport report) (at Library/PackageCache/com.unity.burst@1.6.0/Editor/BurstAotCompiler.cs:514)
    22. Unity.Burst.Editor.BurstAotCompiler.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) (at Library/PackageCache/com.unity.burst@1.6.0/Editor/BurstAotCompiler.cs:186)
    23. UnityEditor.Build.BuildPipelineInterfaces.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) (at <0cde216a590a4d6fbc3d7db7ac203c5d>:0)
    24. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    25.  
    By the sounds of things, the compiler can't get access to a couple files, that I believe are created by Unity, but I am not entirely sure... Does anyone know how to fix this error, as it is preventing me from building my project?
    Thanks!
     
    Last edited: Jan 23, 2022
  2. HearsAWho

    HearsAWho

    Joined:
    Mar 15, 2022
    Posts:
    1
    I came across the same issue, looks like the root can come to a couple major culprits.

    either you have accidently made the folder and its subfolders read only somewhere along the chain:
    C:\Users\[User]\Desktop\UnityFolder\[Game]\Temp\StagingArea\Data

    or as was the case with me your antivirus is stopping the actions mid stream by making files read only as they are generated.

    Heads up Avast still does this even if you "pause" its folder watcher, I had to move my project and the destination build out of Desktop/Documents/Downloads folders to get past this.