Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Copying assembly from directory Temp to Library/ScriptAssemblies failed

Discussion in '2018.2 Beta' started by georgeq, May 31, 2018.

  1. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    I'm trying to build the PC player on 2018.2.06b but the process quits because of this error, it doesn't go away when I hit "Clear" on the console and If I hit play the editor tells me: "All compiler errors have to be fixed before you can enter playmode!", just as if it was a compilation error and obviously it is not.

    I could generate the PC build the first time, but the I realized I didn't update the scene list, so I added the missing scene to the build list and when I tried to "Build and Run" again I got this error. the Temp folder does not exist inside the project's folder. I had to delete the Library folder in order to recover from this, but it took a long while.
     
    briank, BinaryBanana and Mochnant like this.
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Hi George,
    Could you please file a bug report + repro for this issue and reply with the case #?
     
    Mochnant likes this.
  3. 99crusader

    99crusader

    Joined:
    Apr 21, 2014
    Posts:
    7
    I've been having this same issue. Having to restart Unity each time and sometimes that does not fix the error. It happens whenever I add/edit a script and go back into Unity and immediately following the compiling process. (Unity Version : 2018.1.0f2)
     
    VSQUAD, BeyondMASC and MercurialKid like this.
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    If you can reproduce this problem, could you please submit a bug-report, as explained here:
    https://unity3d.com/unity/qa/bug-reporting

    Unity Technologies is probably not able to help you, or repair their software, if nobody with this problem shares the project with them.
     
  5. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    This is moderately common when using the new Incremental Compiler. You guys using it? Forcing a recompilation a few times has, so far, always worked for me. A quick way to force it is to reimport an asmdef file. When it works, you can try creating the build again.
     
    bibbis likes this.
  6. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    Yes, I am using the incremental compiler.
     
  7. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    Case 1044452
     
    Mochnant, LeonhardP and Peter77 like this.
  8. Mochnant

    Mochnant

    Joined:
    Apr 23, 2015
    Posts:
    7
    I have this same issue in 2018.1.3f1.
     
  9. Cucusique

    Cucusique

    Joined:
    Oct 10, 2017
    Posts:
    1
    same issue on 2018.1.of2
     
  10. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    I did run many times into this one, not new to me. The problem is that "Random" exists in at least two namespaces, UnityEngine and System. If you use both namespaces in the same .cs file, the Compiler generates this error.

    In order to fix the error, either clean up the "usings" or use a fully qualified name, such as UnityEngine.Random.Range() instead.
     
    sisermann, splaw, CBra and 1 other person like this.
  11. RowDaBonk

    RowDaBonk

    Joined:
    Jul 19, 2012
    Posts:
    3
    This happened to me on OSX having a project's root folder with an ' character on it's name, the incremental compiler created a new folder at the same level, with the same name but without the ', and only a Temp folder inside.
     
  12. Dom_Laflamme

    Dom_Laflamme

    Unity Technologies

    Joined:
    Sep 25, 2013
    Posts:
    27
    which version of the incremental compiler are you guys using?
     
  13. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Always with the latest one, in my case. Currently 0.0.42-preview.7
     
  14. Rethagos

    Rethagos

    Joined:
    Apr 12, 2018
    Posts:
    1
    Working with Unity 2018.2.0.b9 - Incremental Compiler v0.0.38

    Error "Copying assembly from directory Temp to Library/ScriptAssemblies failed" appears randomly when creating (and possibly modifying - didn't test it but it seems probable) files in a project directory.
    Can't send a bug report, as I can't reproduce the bug itself.

    Creating a dummy file and then deleting it seems to remove the issue whenever it pops up.

    Needs more investigating, though.
     
  15. Dom_Laflamme

    Dom_Laflamme

    Unity Technologies

    Joined:
    Sep 25, 2013
    Posts:
    27
    ok, looking into this issue some more, I need help to isolate the problem.
    I've added some new code which ensures the DLL and PDB are outputted correctly and are writable.
    To help me debug, I'm outputting some additional debugging information.

    Could anyone having this issue upgrade to "0.0.42-preview.9" and set the compiler's verbosity level to "all messages" (in the Edit->Preferences->Compiler.
    Then, if/when the issue comes up again, I would love to see you compiler log, and editor log.
     
  16. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
  17. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
  18. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Last edited: Jun 22, 2018
  19. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Here's the code if anyone wants to try stress testing on their side as well:
    I just quickly extracted from the tool I use for this. It will randomly reimport an asmdef file until the error pops up.
    It only works on projects that have asmdef files.

    Note: the editor might stall forever in a "compiling" state because of the OutOfMemory exception that I mentioned a few posts back. In that case, restart the editor.

    Also, there's probably a way to get the asmdef files that is better than literally iterating over all scripts. Sorry about that, this is quick and dirty.

    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEditor;
    3. using UnityEditor.Compilation;
    4. using UnityEngine;
    5.  
    6. public static class CompilationStressTester {
    7.  
    8.     private const string K_STOP_FLAG = "StopMenuForceRecompileUntilErrorAppears";
    9.  
    10.  
    11.     [MenuItem("Tools/Compilation/" + nameof(ResetCompilationStressTestFlags))]
    12.     private static void ResetCompilationStressTestFlags() {
    13.         EditorPrefs.SetBool(K_STOP_FLAG, false);
    14.     }
    15.  
    16.  
    17.     [MenuItem("Tools/Compilation/Force recompile UNTIL ASSEMBLY COPYING ERROR SHOWS UP")]
    18.     [InitializeOnLoadMethod]
    19.     private static void MenuForceRecompileUntilErrorAppears() {
    20.         if (EditorPrefs.GetBool(K_STOP_FLAG)) {
    21.             UnityEngine.Debug.Log("GOT ERROR. WILL NOT LOOP.");
    22.             return;
    23.         }
    24.  
    25.         UnityEngine.Debug.Log("LOOPING UNTIL THE ERROR SHOWS UP");
    26.         UnityEngine.Application.logMessageReceived -= logMessageReceived;
    27.         UnityEngine.Application.logMessageReceived += logMessageReceived;
    28.         MenuForceRecompile();
    29.     }
    30.  
    31.  
    32.     private static bool TryGetCustomAssemblyForScript(string scriptPath, out string asmdefFilePath) {
    33.         asmdefFilePath = CompilationPipeline.GetAssemblyDefinitionFilePathFromScriptPath(scriptPath);
    34.         return !string.IsNullOrEmpty(asmdefFilePath);
    35.     }
    36.  
    37.  
    38.     private static void MenuForceRecompile() {
    39.         var allScripts = MonoImporter.GetAllRuntimeMonoScripts();
    40.         var asmdefFiles = new HashSet<string>();
    41.         foreach (var monoScript in allScripts) {
    42.             var scriptPath = AssetDatabase.GetAssetPath(monoScript);
    43.             if (TryGetCustomAssemblyForScript(scriptPath, out var asmdefFilePath)) {
    44.                 asmdefFiles.Add(asmdefFilePath);
    45.             }
    46.         }
    47.  
    48.         if (asmdefFiles.Count == 0) {
    49.             UnityEngine.Debug.LogWarning("Coult not find any amsdef files. Failed to force a recompilation!");
    50.             return;
    51.         }
    52.  
    53.         //randomly reimport one
    54.         var toReimportIndex = UnityEngine.Random.Range(0, asmdefFiles.Count - 1);
    55.         var asmdefFilePathToReimport = asmdefFiles.ToList()[toReimportIndex];
    56.         UnityEngine.Debug.Log($"Reimporting {asmdefFilePathToReimport} to trigger a recompilation.");
    57.         AssetDatabase.ImportAsset(asmdefFilePathToReimport, ImportAssetOptions.ForceSynchronousImport);
    58.     }
    59.  
    60.  
    61.     private static void logMessageReceived(string condition, string stackTrace, LogType type) {
    62.         if (type == LogType.Error || (condition?.Contains("assembly") == true && condition?.Contains("failed") == true)) {
    63.             UnityEngine.Application.logMessageReceived -= logMessageReceived;
    64.             EditorPrefs.SetBool(K_STOP_FLAG, true);
    65.             UnityEngine.Debug.Log("GOT ERROR. STOPPING LOG MONITORING.");
    66.         }
    67.     }
    68.  
    69. }