Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Directory Not Found Exception when building local "Packed Assets" Player Content

Discussion in 'Addressables' started by patcarver, Mar 8, 2019.

  1. patcarver

    patcarver

    Joined:
    Jul 13, 2016
    Posts:
    5
    Hey Bill,

    I seem to be getting an error when trying to build player content to streaming assets. Could it be related to changing the path's according to the release instructions?

    Here are my addressable settings.
    upload_2019-3-8_14-0-20.png

    upload_2019-3-8_14-0-51.png

    Code (CSharp):
    1. DirectoryNotFoundException: Could not find a part of the path "Temp/com.unity.addressables/AssetBundles\packedassets_assets_fa_de_cassidysinglehandle_597lf-mpu.bundle" or "Assets/StreamingAssets/aa/WebGL \packedassets_assets_fa_de_cassidysinglehandle_597lf-mpu_3224b8fc6756ff3b102c7db123f508b7.bundle"
    2. System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
    3. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode.PostProcessBundles (UnityEditor.AddressableAssets.Settings.AddressableAssetGroup assetGroup, System.Collections.Generic.List`1[T] bundles, UnityEditor.Build.Pipeline.Interfaces.IBundleBuildResults buildResult, UnityEditor.Build.Pipeline.Interfaces.IWriteData writeData, UnityEngine.AddressableAssets.Initialization.ResourceManagerRuntimeData runtimeData, System.Collections.Generic.List`1[T] locations) (at Library/PackageCache/com.unity.addressables@0.6.7-preview/Editor/Build/DataBuilders/BuildScriptPackedMode.cs:424)
    4. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode.BuildData[TResult] (UnityEditor.AddressableAssets.Build.IDataBuilderContext context) (at Library/PackageCache/com.unity.addressables@0.6.7-preview/Editor/Build/DataBuilders/BuildScriptPackedMode.cs:183)
    5. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings.BuildPlayerContent () (at Library/PackageCache/com.unity.addressables@0.6.7-preview/Editor/Settings/AddressableAssetSettings.cs:1416)
    6. UnityEditor.AddressableAssets.GUI.AddressableAssetsSettingsGroupEditor.OnBuildPlayerData () (at Library/PackageCache/com.unity.addressables@0.6.7-preview/Editor/GUI/AddressableAssetsSettingsGroupEditor.cs:233)
    7. UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at C:/buildslave/unity/build/Editor/Mono/GUI/GenericMenu.cs:121)
    8.  
     
    CharBodman likes this.
  2. RecursiveFrog

    RecursiveFrog

    Joined:
    Mar 7, 2011
    Posts:
    188
    I had a similar error. I resolved it by manually deleting the addressable_asset_state.bin and all my addressable asset bundles, and starting a fresh build. I also had to restart the editor after all that.
     
  3. patcarver

    patcarver

    Joined:
    Jul 13, 2016
    Posts:
    5
    Thanks for the suggestion! Unfortunately it didn't work. Still hoping for some help w/ this.
     
  4. patcarver

    patcarver

    Joined:
    Jul 13, 2016
    Posts:
    5
    Not sure what I did wrong here but after copying the addressable settings from a fresh project and re-setting up my groups everything works now. I'll keep this thread here in case anyone else comes across it. Thanks.
     
  5. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    967
    This feels like a case of Unity keeping some bad data around in the Library folder. If anyone gets a clean way to repro this, we'd be happy to look into it.
     
  6. libra34567

    libra34567

    Joined:
    Apr 5, 2014
    Posts:
    28
    @unity_bill I also met the same situation, seems like, if the default platform is standalone, and you build player content in addressable, It will geenrate folder with Windows/addressable_asset_state.bin etc, everything is fine. but when you switch platform, and build player content, it will not generate one for WebGL, i fixed it by deleting library, AddressableAssetsData, as well as removing addressable pakacge and reimporting it. Not sure which one of them fix the problem tho
     
  7. DarkVerse

    DarkVerse

    Joined:
    Jan 9, 2017
    Posts:
    40
    I am getting the same thing after updating from 0.6.8 to 0.7.5
    I have deleted everything in Library/com.unity.addressables removed all previous bundles and addressable_content_state.bin and removed everything in BuildCache and done a Clean/All.
    No luck, still getting part of directory path not found error. I have checked both paths in the message and all folders are there.
    I have seen something similar in the past where it is NOT beginning at the usual root folder, is there something funky going on with that perhaps?

    Deleting all of Library did not work either.
     
    Last edited: May 1, 2019
  8. DarkVerse

    DarkVerse

    Joined:
    Jan 9, 2017
    Posts:
    40
    It appear that this is a manifestation of the 260 character limit on file path in windows - see https://forum.unity.com/threads/solved-directorynotfoundexception-with-different-packages.643297/

    I checked and the resultant path after the attempted copy would be 264 characters. I am enabling long paths in windows and will see if that fixes it, otherwise I will map a drive letter as suggested in the above linked thread.

    Update: I enabled long paths in Windows 10, rebooted and cleared all caches but that made no difference. I moved the Unity project to a folder with a shorter path (ie closer to root) and that did work. In my case it was definitely the path length problem but it was not sufficient to turn on long paths, presumably Unity itself is truncating the path to 260 characters.
     
    Last edited: May 1, 2019
  9. brgishy

    brgishy

    Joined:
    Jul 9, 2013
    Posts:
    20
    I too am hitting this bug and it's extremely debilitating. I was able to fix this bug in the Addressables code by using the UnityEditor.FileUtil class instead of the normal System.IO.File and System.IO.Directory classes.

    com.unity.addressables@0.8.0-preview\Editor\Build\DirectoryUtility.cs
    Replace line 39
    file.CopyTo(temppath, true);
    with
    UnityEditor.FileUtil.ReplaceFile(file.FullName, temppath);

    com.unity.addressables@0.8.0-preview\Editor\Build\DataBuilders\BuildScriptPackedMode.cs
    Replace line 557
    File.Copy(Path.Combine(assetGroup.Settings.buildSettings.bundleBuildPath, originalBundleName), targetPath, true);
    with
    UnityEditor.FileUtil.CopyFileOrDirectory(Path.Combine(assetGroup.Settings.buildSettings.bundleBuildPath, originalBundleName), targetPath);

    com.unity.addressables@0.8.0-preview\Editor\Settings\AddressableAssetSettings.cs
    Replace line 1606
    Directory.Delete(Addressables.BuildPath, true);
    with
    UnityEditor.FileUtil.DeleteFileOrDirectory(Addressables.BuildPath);

    By making the above three changes I was able to get "Build Player Content" working again, but the build still fails in "C:/buildslave/unity/build/Editor/Mono/FileUtil.cs" which is using System.IO classes instead of the UnityEdtior.FileUtil class as well.

    @unity_bill, is it possible to update Addressables and the build system to use UnityEditor.FiltUtil instead of the normal System.IO classes?
     
  10. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    967
    I'm not sure. we'll look into it.
     
    brgishy likes this.
  11. RyanAndal

    RyanAndal

    Joined:
    Sep 19, 2017
    Posts:
    3
    Hi,
    We are running into this issue as well - we are using Unity 2019.1.0f2
    @unity_bill did you have a chance to look into it ?
     
  12. Greyborn

    Greyborn

    Joined:
    May 26, 2016
    Posts:
    46
    Found this thread because we are having a similar issue where it looks to be exceeding the OS' path character limit.

    The Addressable system adds a TON of extra characters to the entry's output name/path. A workaround for now is to manually rename the entry to remove some/all of the extra path text included in the default name it gives (or just right-click the entry and choose "Simplify Entry Names") so the resulting paths and file names are shorter.

    On a related note/request - it would be nice if the "Simplify Entry Names" feature would optionally allow us to keep the file's extension in the name so it is easier to tell at a glance if it's a material, texture, prefab, scene file etc. The little type icons isn't the most effective way to get that type information quickly.
     
    Last edited: Jul 11, 2019
  13. MagicDesignEmerick

    MagicDesignEmerick

    Joined:
    Oct 4, 2017
    Posts:
    14
    @unity_bill I ran into the same issue, and ttried with 1.1.7 to set bundle name to Only Hash but either I'm missing something or it doesn't seem to work :
    Code (CSharp):
    1. FileNotFoundException: Library/BuildCache/2b/2bd5b19c5677a7c8efa3723b7b6cb244/c15d5414109e80c896dbbb7747937356/anim_data-lizard_anim_swordandshield_skeletondata_animdata_assets_lizard_anim_swordandshield_skeletondata_animdata.bundle does not exist
    It clearly uses the name here, and I see that also during the progressbar dialog, each bundle name is using the name of the asset (though it might be just to be clearer).

    Moreover, simplifying entries doesn't seem to fix the filename issue for me, I had to rename the AssetGroup name.
     
  14. xLeo

    xLeo

    Joined:
    Sep 21, 2010
    Posts:
    24
    "Simplify Entry Names" workaround "fixed" the issue for us.
    We have also tried to configure Windows to handle long paths but that didn't work out... :(
     
  15. dnnkeeper

    dnnkeeper

    Joined:
    Jul 7, 2013
    Posts:
    66
    Here I wrote a custom analyze rule for shortening long addresses by omitting path in addresses that longer than 64 characters:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEditor;
    4. using UnityEditor.AddressableAssets.GUI;
    5. using UnityEditor.AddressableAssets.Settings;
    6. using UnityEditor.AddressableAssets.Settings.GroupSchemas;
    7. using UnityEngine;
    8. public class AddressNameShortener : UnityEditor.AddressableAssets.Build.AnalyzeRules.AnalyzeRule
    9. {
    10.     public override bool CanFix
    11.     {
    12.         get { return true; }
    13.         set { }
    14.     }
    15.  
    16.     public override string ruleName
    17.     {
    18.         get { return "Ensure all addresses are short"; }
    19.     }
    20.  
    21.     List<AnalyzeResult> tooLongNamesResult;
    22.  
    23.     [SerializeField]
    24.     internal HashSet<string> tooLongNamedAssetsGUIDs;
    25.  
    26.     public override List<AnalyzeResult> RefreshAnalysis(AddressableAssetSettings settings)
    27.     {
    28.         ClearAnalysis();
    29.         tooLongNamedAssetsGUIDs = new HashSet<string>();
    30.         tooLongNamesResult = new List<AnalyzeResult>();
    31.         foreach (var group in settings.groups)
    32.         {
    33.             if (group.HasSchema<PlayerDataGroupSchema>())
    34.                 continue;
    35.  
    36.             foreach (var e in group.entries)
    37.             {
    38.                 if (e.address.Length > 64)
    39.                 {
    40.                     tooLongNamesResult.Add(new AnalyzeResult { resultName = group.Name + kDelimiter + e.address, severity = MessageType.Error });
    41.                     tooLongNamedAssetsGUIDs.Add(e.guid);
    42.                 }
    43.             }
    44.         }
    45.  
    46.         if (tooLongNamesResult.Count == 0)
    47.             tooLongNamesResult.Add(new AnalyzeResult { resultName = ruleName + " - No issues found." });
    48.  
    49.         return tooLongNamesResult;
    50.     }
    51.  
    52.     public override void FixIssues(AddressableAssetSettings settings)
    53.     {
    54.         if (tooLongNamesResult == null)
    55.             RefreshAnalysis(settings);
    56.  
    57.         if (tooLongNamesResult.Count == 0)
    58.             return;
    59.  
    60.         foreach (var assetGuid in tooLongNamedAssetsGUIDs)
    61.         {
    62.             var entry = settings.FindAssetEntry( assetGuid );
    63.             int LastIndex = entry.address.LastIndexOf('/')+1;
    64.             string assetName = entry.address.Substring(LastIndex, entry.address.Length-LastIndex);
    65.             entry.address = assetName;
    66.         }
    67.     }
    68. }
    69.  
    70.  
    71. [InitializeOnLoad]
    72. class RegisterAddressNameShortener
    73. {
    74.     static RegisterAddressNameShortener()
    75.     {
    76.         AnalyzeWindow.RegisterNewRule<AddressNameShortener>();
    77.     }
    78. }
    79.  
     
    unity_bill likes this.