mx clean failing on .gitignore files

Stefan Marr java at stefan-marr.de
Tue Apr 7 20:39:48 UTC 2015


Hi:

I had it already a couple if times the issue that `mx clean` failed with a stack trace like the one at the end of the mail.
The problem is that the used shutil.rmtree() function only works for proper directories.
But for clean iterates over all files likes this: `f in os.listdir(genDir):`.

So, perhaps something like the patch below would be better to avoid such errors.

Best regards
Stefan


Patch:

diff --git a/mxtool/mx.py b/mxtool/mx.py
index d5fbf14..6f2b6a4 100755
--- a/mxtool/mx.py
+++ b/mxtool/mx.py
@@ -3349,7 +3349,11 @@ def clean(args, parser=None):
                 if genDir != '' and exists(genDir):
                     log('Clearing {0}...'.format(genDir))
                     for f in os.listdir(genDir):
-                        _rmtree(join(genDir, f))
+                        f_path = join(genDir, f)
+                        if os.path.isdir(f_path):
+                            _rmtree(f_path)
+                        else:
+                            _rmIfExists(f_path)


                 outputDir = p.output_dir()



Stack Trace:
  File "/Users/smarr/Projects/PostDoc/Truffle/graal/mx/mx_graal.py", line 170, in clean
    opts = mx.clean(args, parser=ArgumentParser(prog='mx clean'))
  File "/Users/smarr/Projects/PostDoc/Truffle/graal/mxtool/mx.py", line 3352, in clean
    _rmtree(join(genDir, f))
  File "/Users/smarr/Projects/PostDoc/Truffle/graal/mxtool/mx.py", line 3336, in _rmtree
    shutil.rmtree(path)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 239, in rmtree
    onerror(os.listdir, path, sys.exc_info())
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 237, in rmtree
    names = os.listdir(path)
OSError: [Errno 20] Not a directory: '../graal/graal/com.oracle.graal.compiler/src_gen/.gitignore’

-- 
Stefan Marr
INRIA Lille - Nord Europe
http://stefan-marr.de/research/





More information about the graal-dev mailing list