-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
- Cookiecutter version: 2.4.0
- Template project url: N/A
- Python version: 3.10
- Operating System: Linux
Description:
I just learned about the new pre_prompt in 2.4.0. It's exactly what I wanted. Thanks for the new feature. When I develop the templates sometimes I will just run the cookiecutter in the same directory: cookiecutter .. With pre_prompt defined it will crash with an error saying the temporary directory already exists:
Traceback (most recent call last):
File "/envs/cookiecutter/bin/cookiecutter", line 10, in <module>
sys.exit(main())
File "/envs/cookiecutter/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/envs/cookiecutter/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/envs/cookiecutter/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/envs/cookiecutter/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/envs/cookiecutter/lib/python3.10/site-packages/cookiecutter/cli.py", line 202, in main
cookiecutter(
File "/envs/cookiecutter/lib/python3.10/site-packages/cookiecutter/main.py", line 91, in cookiecutter
repo_dir = run_pre_prompt_hook(base_repo_dir) if accept_hooks else repo_dir
File "/envs/cookiecutter/lib/python3.10/site-packages/cookiecutter/hooks.py", line 179, in run_pre_prompt_hook
repo_dir = create_tmp_repo_dir(repo_dir)
File "/envs/cookiecutter/lib/python3.10/site-packages/cookiecutter/utils.py", line 128, in create_tmp_repo_dir
shutil.copytree(repo_dir, new_dir)
File "/envs/cookiecutter/lib/python3.10/shutil.py", line 559, in copytree
return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
File "/envs/cookiecutter/lib/python3.10/shutil.py", line 457, in _copytree
os.makedirs(dst, exist_ok=dirs_exist_ok)
File "/envs/cookiecutter/lib/python3.10/os.py", line 225, in makedirs
mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/tmp/cookiecutter7yw9w4f5/'
It seems the temporary sub-directory name depends on the directory name of the repository, "." probably resolves to nothing and it will try to create the parent directory instead, so if I use the absolute path of the current directory it works: cookiecutter $(pwd). It feels like a possible fix is just to compute the absolute path of the input path first. Thanks.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugThis issue/PR relates to a bug.This issue/PR relates to a bug.