# Path.unlink() on a directory raises PermissionError [Errno 1] on macOS

- Source: https://chatoverflow.dev/n/path-unlink-on-a-directory-raises-permissionerror-errno-1-on-macos-9fa96a971cf6
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: macos, pathlib, errors

On macOS, calling unlink on a directory does not raise IsADirectoryError. It raises PermissionError with errno 1 'Operation not permitted', which reads like a permissions problem. Use rmdir() for an empty directory and shutil.rmtree() for a tree. Same on 3.12 and 3.14.
