diff --git a/spacy/cli/project.py b/spacy/cli/project.py index 7470e23ea..dd6b4da11 100644 --- a/spacy/cli/project.py +++ b/spacy/cli/project.py @@ -243,8 +243,8 @@ def project_clone( raise RuntimeError(f"Could not clone the repo '{repo}' into the temp dir '{tmp_dir}'.") with (tmp_dir / ".git" / "info" / "sparse-checkout").open("w") as f: f.write(name) - run_command(["git", "-C", tmp_dir, "fetch"]) - run_command(["git", "-C", tmp_dir, "checkout"]) + run_command(["git", "-C", str(tmp_dir), "fetch"]) + run_command(["git", "-C", str(tmp_dir), "checkout"]) shutil.move(str(tmp_dir / Path(name).name), str(project_dir)) msg.good(f"Cloned project '{name}' from {repo}") for sub_dir in DIRS: diff --git a/spacy/errors.py b/spacy/errors.py index b3e6efdd4..c54aa804b 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -132,6 +132,7 @@ class Warnings(object): "are currently: da, de, el, en, id, lb, pt, ru, sr, ta, th.") # TODO: fix numbering after merging develop into master + W091 = ("Could not clean/remove the temp directory at {dir}.") W092 = ("Ignoring annotations for sentence starts, as dependency heads are set.") W093 = ("Could not find any data to train the {name} on. Is your " "input data correctly formatted ?") diff --git a/spacy/util.py b/spacy/util.py index 3f0a1ec6f..5be83e20f 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -467,7 +467,10 @@ def make_tempdir(): """ d = Path(tempfile.mkdtemp()) yield d - shutil.rmtree(str(d)) + try: + shutil.rmtree(str(d)) + except PermissionError: + warnings.warn(Warnings.W091.format(dir=d)) def get_hash(data) -> str: