Clear out existing virtualenv when creating

We check whether a virtualenv has been created successfully by the
spec file that is written after the virtualenv has been initialized
and the spec requirements installed.  In the event that a previous run
failed before the spec file was written, we want to clear out the
partially created virtualenv and recreate it fresh.

TEST=virtualenv VM tests

Change-Id: I060f1fa54cea1ac6042a29215d67617ae563a487
Commit-Ready: Allen Li <>
Tested-by: Allen Li <>
Reviewed-by: Aviv Keshet <>
diff --git a/cros_venv/ b/cros_venv/
index 1991bc0..16524fd 100644
--- a/cros_venv/
+++ b/cros_venv/
@@ -277,7 +277,8 @@
     # does not document it.  Once we no longer have any hosts on
     # virtualenv 1.7, the --setuptools option can be removed.
     command = ['virtualenv', venvdir, '-p', _VENV_PY,
-               '--extra-search-dir', _PACKAGE_DIR, '--setuptools']
+               '--extra-search-dir', _PACKAGE_DIR, '--setuptools',
+               '--clear']
     _log_check_call(command, logfile=logfile)