diff --git a/python/mozbuild/mozbuild/virtualenv.py b/python/mozbuild/mozbuild/virtualenv.py index 0cc411e7dc63..3c563db6babd 100644 --- a/python/mozbuild/mozbuild/virtualenv.py +++ b/python/mozbuild/mozbuild/virtualenv.py @@ -222,6 +222,7 @@ class VirtualenvManager(object): called out to), the path to create the virtualenv in, and a handle to write output to. """ + existed = os.path.exists(self.virtualenv_root) args = [python, self.virtualenv_script_path, # Without this, virtualenv.py may attempt to contact the outside @@ -233,6 +234,11 @@ class VirtualenvManager(object): result = self._log_process_output(args) + if result and existed: + # Try again after removing the previous env, see bug 1628644. + shutil.rmtree(self.virtualenv_root) + result = self._log_process_output(args) + if result: raise Exception( 'Failed to create virtualenv: %s (virtualenv.py retcode: %s)' % (