# PermissionError: [Errno 13] Permission denied: '/tmp/pytest-of-user/pytest-123/test_0/'

- **ID:** `python/pytest-tmpdir-permission-denied`
- **Domain:** python
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The pytest tmpdir fixture cannot create or access a temporary directory due to insufficient permissions, often in restricted environments like containers.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Set a custom temp directory with write permissions: `pytest --basetemp=/home/user/tmp`
   ```
2. **** (85% success)
   ```
   Use the `tmp_path` fixture instead of `tmpdir` (returns pathlib.Path) and ensure the parent directory is writable.
   ```

## Dead Ends

- **** — This is a security risk and may not be allowed in containerized environments; also, the issue might be with specific subdirectories. (80% fail)
- **** — Running tests as root is dangerous and can mask permission issues that would occur in production. (90% fail)
