microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

System.IO.DirectoryNotFoundException when importing MRTK into project with long path #9457

Closed SahilMayenkar closed 9 months ago

SahilMayenkar commented 3 years ago

Describe the bug

When importing the MRTK into a new Unity project with a path length greater than 57 characters, a System.IO.DirectoryNotFoundException is raised. This also seems to prevent the shaders from automatically being copied into the Assets folder upon import, which can result in further errors if the project needs to upgrade the shaders for URP.

To reproduce

Steps to reproduce the behavior:

  1. Create a new Unity project with a long path length of 58+ characters (e.g. C:/Documents/A Pretty Long Path Here/Example Unity Project)
  2. Import MRTK 2.6.0 using Mixed Reality Feature tool.

Expected behavior

No errors upon import, and shaders are imported into Assets/MRTK/Shaders folder.

Possible updates to docs on the longest path length.

Screenshots

image

Your setup (please complete the following information)

Additional context

This issue also affects MRTK 2.5.4, but to a lesser degree. There were no errors upon import on projects with the same path length of 58 and even a longer path length of 80, but a path length of 115 resulted in a similar error as above. However, a cutoff threshold for the path length of somewhere between 80-115 characters seems more reasonable.

keveleigh commented 3 years ago

Hmm, I wonder if this is a problem with spaces or a problem with path length. That path in the screen shot is pretty long 😅

SahilMayenkar commented 3 years ago

Nice catch! The actual project path didn't seem too long at first (just 'D:\Documents\Some Folder with Spaces\Example Unity Project`), but it looks like the full path in the screenshot is from the package cache of the MRTK foundation package that was just imported, which does admittedly become pretty long.

I tested out your theory on a new Unity project with an equally long path not containing spaces and it resulted in the same error, so I think you might be right. I've updated the issue above accordingly.

I also tested it out with a variety of different path lengths, and 58 characters was the point at which the error starts appearing with MRTK 2.6.0. MRTK 2.5.4 seems to be able to withstand longer path lengths however.

FlorianJa commented 3 years ago

I am running into a very similar problem with the 2.6 release. I could fix the problem since the path to …\Library\PackageCache... was quite long for my project. However, there is this "@635490bc259e-1615042220629" added to the package name. These are 27 characters. Are they necessary?

polar-kev commented 3 years ago

@davidkline-ms, these characters are appended by Unity and not MRTK, correct?

david-c-kline commented 3 years ago

This is rooted around a limitation of Unity (it is not long path aware).

Some work has been performed on this as part of #9570. More work is queued up to analyze the lengths of files such as default profiles.

The expectation is that MRTK will not be able to 100% solve this issue (a project root could be constructed that will cause any package to exceed the limit), though the team will continue to look for ways to reduce extremely long path and file names.

These changes are expected to be introduced throughout the coming MRTK releases (2.7.0, 2.7.x, 3.x).

stale[bot] commented 2 years ago

This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.

IssueSyncBot commented 9 months ago

We appreciate your feedback and thank you for reporting this issue.

Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.

Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.

Please note that MRTK3 was released in August 2023. It features an all-new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visit https://www.mixedrealitytoolkit.org.

Thank you for your continued support of the Mixed Reality Toolkit!