diff options
-rw-r--r-- | lib/spack/llnl/util/filesystem.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index 6b2ba50c0e..308c6154e1 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -1624,6 +1624,12 @@ def remove_linked_tree(path): shutil.rmtree(os.path.realpath(path), **kwargs) os.unlink(path) else: + if sys.platform == "win32": + # Adding this prefix allows shutil to remove long paths on windows + # https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry + long_path_pfx = "\\\\?\\" + if not path.startswith(long_path_pfx): + path = long_path_pfx + path shutil.rmtree(path, **kwargs) |