diff --git a/conda_pack/formats.py b/conda_pack/formats.py index 39d9cfc..cc5c8cb 100644 --- a/conda_pack/formats.py +++ b/conda_pack/formats.py @@ -506,6 +506,10 @@ def _add(self, source, target): self.copy_func = partial(shutil.copy2, follow_symlinks=False) if os.path.isfile(source) or os.path.islink(source): + if os.path.islink(target_abspath) or os.path.isfile(target_abspath): + os.remove(target_abspath) + elif os.path.isdir(target_abspath): + shutil.rmtree(target_abspath) self.copy_func(source, target_abspath) else: os.mkdir(target_abspath)