diff --git a/lithops/localhost/v1/localhost.py b/lithops/localhost/v1/localhost.py index bc83c8505..5d2cd9cfc 100644 --- a/lithops/localhost/v1/localhost.py +++ b/lithops/localhost/v1/localhost.py @@ -213,8 +213,9 @@ def _copy_lithops_to_tmp(self): if is_lithops_worker() and os.path.isfile(RUNNER_FILE): return os.makedirs(LITHOPS_TEMP_DIR, exist_ok=True) - shutil.rmtree(os.path.join(LITHOPS_TEMP_DIR, 'lithops'), ignore_errors=True) - shutil.copytree(LITHOPS_LOCATION, os.path.join(LITHOPS_TEMP_DIR, 'lithops')) + dst_path = os.path.join(LITHOPS_TEMP_DIR, 'lithops') + shutil.rmtree(dst_path, ignore_errors=True) + shutil.copytree(LITHOPS_LOCATION, dst_path, dirs_exist_ok=True) src_handler = os.path.join(LITHOPS_LOCATION, 'localhost', 'v1', 'runner.py') copyfile(src_handler, RUNNER_FILE) diff --git a/lithops/localhost/v2/localhost.py b/lithops/localhost/v2/localhost.py index 357681689..a873104af 100644 --- a/lithops/localhost/v2/localhost.py +++ b/lithops/localhost/v2/localhost.py @@ -204,8 +204,9 @@ def _copy_lithops_to_tmp(self): if is_lithops_worker() and os.path.isfile(RUNNER_FILE): return os.makedirs(LITHOPS_TEMP_DIR, exist_ok=True) - shutil.rmtree(os.path.join(LITHOPS_TEMP_DIR, 'lithops'), ignore_errors=True) - shutil.copytree(LITHOPS_LOCATION, os.path.join(LITHOPS_TEMP_DIR, 'lithops')) + dst_path = os.path.join(LITHOPS_TEMP_DIR, 'lithops') + shutil.rmtree(dst_path, ignore_errors=True) + shutil.copytree(LITHOPS_LOCATION, dst_path, dirs_exist_ok=True) src_handler = os.path.join(LITHOPS_LOCATION, 'localhost', 'v2', 'runner.py') copyfile(src_handler, RUNNER_FILE)