Command /usr/sbin/chown failed with exit code 1 when Archiving
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The error Command /usr/sbin/chown failed with exit code 1 appears when a build or archive process tries to change file ownership but lacks the required permissions. In Xcode, this happens during the "Copy Bundle Resources" or "Archive" phase when the build system runs chown on files owned by another user. On Linux, it occurs when a non-root user tries to change file ownership during tar extraction or package building. The fix depends on context. In Xcode it is usually a project configuration issue, and on Linux it is a permissions issue.
Xcode Context: The Most Common Case
This error frequently appears when archiving iOS/macOS apps in Xcode:
Fix 1: Install Manifest Ownership
Open your target's Build Settings and change:
Or in Xcode UI: Build Settings > search "Install Owner" > set to empty.
When INSTALL_OWNER is set, Xcode runs chown to change file ownership during archiving. If the build user does not have permission to change ownership to the specified user, the command fails.
Fix 2: Check File Permissions in Project
Files copied into the project from another machine or extracted from archives may have different ownership.
Fix 3: Clean Build Folder
Stale build artifacts with incorrect ownership can cause this error on subsequent archives.
Fix 4: CocoaPods / SPM Dependencies
Third-party dependencies sometimes include files with incorrect permissions:
Fix 5: Check Build Phase Scripts
Review "Run Script" build phases for chown commands that may fail:
Linux Context
During tar Extraction
During Package Building (dpkg, rpm)
fakeroot intercepts system calls like chown and pretends they succeed without actually changing ownership.
Docker Build Context
In multi-stage builds, files may carry unexpected ownership from the build stage.
Understanding chown
Why Non-Root Cannot chown
Unix security model: only root can give files to other users. This prevents users from creating files that appear to be owned by root, which would be a security risk (setuid attacks, quota evasion).
Diagnosing the Error
In Xcode, expand the error in the build log to see the exact chown command and its arguments.
CI/CD Pipelines
Common Pitfalls
- Running Xcode as root: Never run Xcode with
sudo. It creates files owned by root that later builds cannot modify. If you have root-owned files in DerivedData, delete them:sudo rm -rf ~/Library/Developer/Xcode/DerivedData. - INSTALL_OWNER in Debug builds:
INSTALL_OWNERis only relevant for Archive/Release builds. If it is set, clear it unless you have a specific reason (enterprise distribution with custom ownership). - Ignoring the error and retrying: The error will persist until the ownership is fixed. Running the archive again does not help. Fix the file permissions first.
- fakeroot not available: On macOS,
fakerootis not installed by default. Use Homebrew:brew install fakeroot. On Linux, install via your package manager. - Mounted volumes in Docker: Files on mounted volumes keep host ownership. Inside the container,
chownon a mounted volume may fail depending on the mount configuration. Use--userflag or named volumes instead.
Summary
- In Xcode: clear
INSTALL_OWNERandINSTALL_GROUPbuild settings, fix file ownership withchown -R $(whoami):staff . - On Linux: use
tar --no-same-ownerfor extraction,fakerootfor package building - Only root can change file ownership to a different user. This is a Unix security constraint
- Check the Xcode build log for the exact
chowncommand to identify the problematic file - In CI/CD: fix ownership after checkout with
sudo chown -R - Clean DerivedData when stale artifacts have incorrect ownership

