{
  "id": "python/pytest-tmp-path-permissions",
  "signature": "PermissionError: [Errno 13] Permission denied: '/tmp/pytest-of-root/pytest-0/test_x0/out.txt'",
  "signature_zh": "PermissionError：[Errno 13] 权限被拒绝：'/tmp/pytest-of-root/pytest-0/test_x0/out.txt'",
  "regex": "PermissionError:\\ \\[Errno\\ 13\\]\\ Permission\\ denied:\\ '/tmp/pytest\\-of\\-root/pytest\\-0/test_x0/out\\.txt'",
  "domain": "python",
  "category": "system_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "在一个环境中以 root 运行的测试留下了由 root 拥有的 /tmp/pytest-of-root；随后以其他用户运行无法写入同一个 tmp_path 基础目录。",
  "versions": [
    {
      "version": "7.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Security risk and the next root run recreates restrictive perms.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "May still collide if /var/tmp/pytest-of-root exists from a root run.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Loses pytest cleanup guarantees and can leave garbage.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "# pytest.ini\n[pytest]\naddopts = --basetemp=/home/ci/pytest-tmp\n# ensure /home/ci/pytest-tmp exists and is writable",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "sudo rm -rf /tmp/pytest-of-root\npytest tests/",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-11-04",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}