[Bug]: PermissionError on cleanup
Author: GigahawkCreated Apr 13, 2026Updated Apr 13, 2026
Labelsbug
What happened?
Calling cookiecutter from this application like so:
However, when cookiecutter tries to delete the directory under /tmp I get:
? DevOps support (CI/CD)? GitHub Actions
- output: /home/jasper/repos/InventreeDigikeyPlugin
Traceback (most recent call last):
File "/nix/store/pzdalg368npikvpq4ncz2saxnz19v53k-python3-3.13.12/lib/python3.13/shutil.py", line 696, in _rmtree_safe_fd
os.unlink(entry.name, dir_fd=topfd)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: 'cookiecutter.json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/nix/store/pzdalg368npikvpq4ncz2saxnz19v53k-python3-3.13.12/lib/python3.13/shutil.py", line 700, in _rmtree_safe_fd
onexc(os.unlink, fullname, err)
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/pzdalg368npikvpq4ncz2saxnz19v53k-python3-3.13.12/lib/python3.13/shutil.py", line 754, in onexc
return onerror(func, path, exc_info)
File "/nix/store/0vlwxl4rv0dhyxq1dq8h5dv23hr9bvh9-python3.13-cookiecutter-2.6.0/lib/python3.13/site-packages/cookiecutter/utils.py", line 26, in force_delete
func(path)
~~~~^^^^^^
PermissionError: [Errno 13] Permission denied: PosixPath('/tmp/cookiecuttertggyjd_7/template')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/nix/store/n4navmfkzzfbxidixszjggqfwcfzrjxp-inventree-1.15.1/bin/.create-inventree-plugin-wrapped", line 9, in <module>
sys.exit(main())
~~~~^^
File "/nix/store/n4navmfkzzfbxidixszjggqfwcfzrjxp-inventree-1.15.1/lib/python3.13/site-packages/plugin_creator/cli.py", line 197, in main
cookiecutter(
~~~~~~~~~~~~^
src_path,
^^^^^^^^^
...<3 lines>...
overwrite_if_exists=True,
^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/nix/store/0vlwxl4rv0dhyxq1dq8h5dv23hr9bvh9-python3.13-cookiecutter-2.6.0/lib/python3.13/site-packages/cookiecutter/main.py", line 194, in cookiecutter
rmtree(repo_dir)
~~~~~~^^^^^^^^^^
File "/nix/store/0vlwxl4rv0dhyxq1dq8h5dv23hr9bvh9-python3.13-cookiecutter-2.6.0/lib/python3.13/site-packages/cookiecutter/utils.py", line 34, in rmtree
shutil.rmtree(path, onerror=force_delete)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/pzdalg368npikvpq4ncz2saxnz19v53k-python3-3.13.12/lib/python3.13/shutil.py", line 763, in rmtree
_rmtree_safe_fd(stack, onexc)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "/nix/store/pzdalg368npikvpq4ncz2saxnz19v53k-python3-3.13.12/lib/python3.13/shutil.py", line 707, in _rmtree_safe_fd
onexc(func, path, err)
~~~~~^^^^^^^^^^^^^^^^^
File "/nix/store/pzdalg368npikvpq4ncz2saxnz19v53k-python3-3.13.12/lib/python3.13/shutil.py", line 754, in onexc
return onerror(func, path, exc_info)
File "/nix/store/0vlwxl4rv0dhyxq1dq8h5dv23hr9bvh9-python3.13-cookiecutter-2.6.0/lib/python3.13/site-packages/cookiecutter/utils.py", line 26, in force_delete
func(path)
~~~~^^^^^^
PermissionError: [Errno 13] Permission denied: '/tmp/cookiecuttertggyjd_7/template'Looking at the directory the permissions are indeed odd:
jasper@arios:/tmp/ > ls -al ./cookiecuttertggyjd_7
total 40
drwx------ 3 jasper users 4096 Apr 12 21:40 .
drwxrwxrwt 79 root root 28672 Apr 12 21:55 ..
d-w------- 4 jasper users 4096 Dec 31 1969 templateMy guess is this has something to do with the template files being stored inside the nix store which is readonly, but the permissions don't match:
jasper@arios:~/repos/nixpkgs/ > ls -al result/lib/python3.13/site-packages/plugin_creator
total 52
dr-xr-xr-x 4 root root 4096 Dec 31 1969 .
dr-xr-xr-x 4 root root 4096 Dec 31 1969 ..
-r--r--r-- 1 root root 6180 Dec 31 1969 cli.py
-r--r--r-- 1 root root 1400 Dec 31 1969 config.py
-r--r--r-- 1 root root 1559 Dec 31 1969 devops.py
-r--r--r-- 1 root root 3183 Dec 31 1969 frontend.py
-r--r--r-- 1 root root 1156 Dec 31 1969 helpers.py
-r--r--r-- 1 root root 59 Dec 31 1969 __init__.py
-r--r--r-- 1 root root 1998 Dec 31 1969 mixins.py
dr-xr-xr-x 2 root root 4096 Dec 31 1969 __pycache__
dr-xr-xr-x 4 root root 4096 Dec 31 1969 template
-r--r--r-- 1 root root 1117 Dec 31 1969 validators.pySteps to reproduce
Issue is likely specific to nix.
- Checkout https://github.com/NixOS/nixpkgs/pull/509455
- Run
nix build .#inventree-plugin-creator - Run
./result/bin/create-inventree-plugin
Template
https://github.com/inventree/plugin-creator/tree/main/plugin_creator/template
Don't think this is related, since the failure happens at cleanup.
Output / traceback
Cookiecutter version
2.6.0
Python version
3.13
Operating system
Linux
How did you install Cookiecutter?
Other (specify in description)
Additional context
cookiecutter installed via nixpkgs
Source: cookiecutter/cookiecutter