Error -54 is an Apple permissions/file-lock error. It means a program is trying to modify a file that is currently open or locked by another process.
Apple Music frequently reads, writes, and modifies the database structure of your .musiclibrary file while the app is active. When OneDrive's Native Sync Engine (CloudStorage framework) intercepts these rapid file modifications to sync them to the cloud, it places a temporary lock on the file. Apple Music hits that lock, cannot save changes, and throws the -54 error.
Even though you have "Always Keep on This Device" selected, the native engine still hooks deeply into the file system to watch for changes, which triggers the conflict.
Recommended Workarounds
Because this is caused by an underlying architectural change in how OneDrive handles macOS file syncing, you will have to change your library configuration to avoid database corruption.
Keep the Database Local, Sync the Audio Files Only (Recommended)
- Move the Music Library.musiclibrary file back to a local, non-cloud folder (like your default ~/Music directory).
- You can keep your actual music media files (the actual .mp3, .m4a audio files) inside the OneDrive folder. Apple Music handles cloud-stored media files fine; it just cannot handle its central database file being intercepted.
- To do this, change the path under Music > Settings > Files > Music Media folder location to point to OneDrive, but leave the library file itself local.
Use a Local Automated Backup System
- If your main goal is ensuring the library database is backed up, leave the .musiclibrary file local so Apple Music can write to it cleanly.
- Use an app like Time Machine, or a local file scripting utility (like Carbon Copy Cloner) to copy the .musiclibrary file to OneDrive automatically once a day after the Music app is closed.
Check System Permissions
- Another user noted that similar permissions-based -54 errors can sometimes be bypassed by re-verifying app privacy permissions. Go to System Settings > Privacy & Security > Full Disk Access, and ensure the Music app has permissions enabled
- If Music is not there, it can be added with the (+) button at the bottom of the list.
