From 76178f31ca89e81d6f97c3fcf322bd3100322634 Mon Sep 17 00:00:00 2001 From: Jeffrey Salmond Date: Tue, 1 Oct 2019 18:29:10 +0100 Subject: When removing a file from a view, don't fail if it doesn't exist (#12960) Sometimes when remove_file is called on a link, that link is missing (perhaps ctrl-C happened halfway through a previous action). As removing a non-existent file is no problem, this patch changes the behavior so Spack continues rather than stopping with an error. Currently you would see ValueError: /path/to/dir is not a link tree! and now it continues with a warning. --- lib/spack/spack/filesystem_view.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/filesystem_view.py b/lib/spack/spack/filesystem_view.py index 5385ca0803..1701af5501 100644 --- a/lib/spack/spack/filesystem_view.py +++ b/lib/spack/spack/filesystem_view.py @@ -357,6 +357,9 @@ class YamlFilesystemView(FilesystemView): tree.unmerge_directories(view_dst, ignore_file) def remove_file(self, src, dest): + if not os.path.lexists(dest): + tty.warn("Tried to remove %s which does not exist" % dest) + return if not os.path.islink(dest): raise ValueError("%s is not a link tree!" % dest) # remove if dest is a hardlink/symlink to src; this will only -- cgit v1.2.3-70-g09d2