e.g. you’re trying to view the package contents of the “Photos Library” (in /Users/[username]/Pictures/), so you can check an original file, RAW image, etc. – but you’re not thinking properly, accidentally click the wrong option in the menu and send the entire contents to the Recycle Bin by mistake.
You stop the deletion immediately, and the Photo Library isn’t in the Recycle Bin, and still appears to be in the usual location in the Finder, but, on launching Photos (macOS Mojave 10.14.6, in this case) it says it has failed to repair the library and invites you to open another one.
The fix is very simple – first, disconnect your Time Machine drive (or any other automated backup location) to avoid harming your backups.
- close Photos if it’s open
- hold down the command + option (alt) keys while clicking the icon
- the Photos app will open and should immediately offer to repair the library for you.
- supply password when prompted
- wait a while (a few minutes for 80GB of photos in my case) while the photolibraryd process rebuilds the library (you’ll see a fairly accurate progress meter)
- browse / continue to use the library for a while to check everything is still there and ok (mine was).