Messed up Music Library

I have a problem that I’ve not been able to fathom and am hoping someone can help.

I have my Music library on an external SSD (thunderbolt, for what that’s worth). In the library’s “Media” folder are all the songs (mostly in Apple MPEG-4 or AIFF format) that I have either (i) purchased from the iTunes store or (ii) ripped from CD, including some that are not available from Apple. I don’t have an Apple Music (i.e. streaming service) subscription, but I do have iTunes Match.

When I open none of the local media files are seen. The albums and songs are there, but “info” shows their location as being the cloud, not (as I would have expected) a file in the media library. Flipping through the info for various albums and songs, some of the songs that I ripped from CDs are shown as “cloud status matched” “location cloud” – these presumably are ones that iTunes match found – and some as “cloud status uploaded” “location cloud” – presumably those that iTunes match didn’t. If I download a song a duplicate media file is created in the appropriate Media subfolder, so I know that knows about it (I’d initially thought that I may have had Music pointing to the wrong external folder).

I really don’t know when this happened, it could well have been a side effect of installing Big Sur or an even earlier version. I only noticed it because Storm Arwen took out all our power and broadband for a few days. Fine, I thought, I’ll just have to sit by the fire with a whisky and play music from my iPhone to a bluetooth speaker I have. No music actually on the phone despite music being synced through Finder (wired) backups; I was not impressed!

Power back (but no Internet) on again, I plugged the phone into my iMac and opened Finder. Opening the phone sync page, Finder doesn’t see any song, albums or artists either (I guess it uses information from Music). At present the only way I can play music on either my iMac or iPhone is to stream from the cloud, which I really don’t want to do when bandwidth is precious and I already have the media files.

Has anyone any idea what’s going on? Is there a way to force to rebuild its database from the contents of the Media folder?

Any help gratefully received!

Does Music->Preferences->Files show the expected Music Media folder location (i.e. the external SSD)?

Yes, it’s pointing to the media folder on the external drive. I know that knows this because if I have it download a fresh copy of an existing song it creates a duplicate file in the right (artist/album) folder. That’s one of the things that’s so weird.

Maybe try deleting the location and add it back again?

I’ve tried resetting the media folder location in preferences and it doesn’t seem to make any difference. It seems that has for some reason decided that I don’t keep local copies on this device, but there’s no UI to say to go look in the media folder before streaming from the cloud. I don’t suppose anyone knows where and in what format Music keeps its internal state? If it’s a plist, XML or SQLite file I can probably fix it as long as I know what to look for.

There used to be an option to repair the music library but, as of Big Sur, this seems to have been removed. The only other idea I have is to build a new library and import your music again. I’m don’t know how this would affect metadata. You could give it a try with a subset of your full library and see how well it works.

Another idea (it’s a long shot, though): go to Music->Preferences->Advanced and click Reset Cache. I’d be surprised if this had any effect.

All of those things are involved, and Apple has changed them so many times I doubt if anyone knows how it all fits together.

I’ve recently had to go through a similar tale of woe caused by Apple getting confused about whether tracks are on my Mac, in the cloud or both places.

In the end, to restore some sanity, I went for the nuclear option, forcibly rebuild the music library from scratch. I’d already turned off iCloud synching at this point, but I suggest you do so before attempting the following.

Quit out of the Music app, then go into the Music folder in your home folder in Finder. In there is another folder called (confusingly) Music, go in there and either delete or rename the file Music Library.musiclibrary. Now, when you open the Music app again, it should start with a blank slate. Then do File > Import... and point it at your music library folder, then go make a cup of tea or coffee while it processes through that.

I hope that helps!

Thanks for the advice. Bigger fish to fry at the moment as the heating’s gone down!