# PermissionError: [Errno 13] Permission denied: '/tmp/pytest-of-root/pytest-0/test_x0/out.txt'

- **ID:** `python/pytest-tmp-path-permissions`
- **Domain:** python
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Tests run as root in one environment left /tmp/pytest-of-root owned by root; subsequent runs as a different user cannot write into the same tmp_path base.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   # pytest.ini
[pytest]
addopts = --basetemp=/home/ci/pytest-tmp
# ensure /home/ci/pytest-tmp exists and is writable
   ```
2. **** (90% success)
   ```
   sudo rm -rf /tmp/pytest-of-root
pytest tests/
   ```

## Dead Ends

- **** — Security risk and the next root run recreates restrictive perms. (70% fail)
- **** — May still collide if /var/tmp/pytest-of-root exists from a root run. (60% fail)
- **** — Loses pytest cleanup guarantees and can leave garbage. (75% fail)
