Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Recover from a 'Library is locked' iTunes error Apps
Didn't see a hint for this one out there, so I thought I'd throw this out in case anyone else runs into this problem. I was having some kernel panic problems with my Ti Powerbook yesterday (apparently due to a bad USB peripheral) that caused my machine to lock up several times which resulted in a few hard resets of the laptop, which didn't appear to cause any harm.

This morning when I tried to start up iTunes I received an error stating that either the library was locked or I did not have write permission to it. I figured that this was most likely related to the problems I had yesterday, as I was burning a CD during one of the lockups.

After a bit of mucking around the system I was able to come up with this not-so-elegant workaround. I made my changes from the command line, but you should be able to do this from Finder as well.
  1. Make sure iTunes is not running.
  2. Go to your ~/Music/iTunes folder.
  3. Copy the files "iTunes Music Library.xml" and "iTunes 3 Music Library" to "iTunes Music Libary.xml.backup" and "iTunes 3 Music Libary.backup".
  4. Remove the files "iTunes Music Library.xml" and "iTunes 3 Music Library".
  5. Rename "iTunes Music Library.xml.backup" to "iTunes Music Library.xml" and "iTunes 3 Music Library.backup" to "iTunes 3 Music Library".
  6. Relaunch iTunes. Problem should be fixed.
A much more elegant way to fix this would be to determine where iTunes stores information regarding which files are locked, but I was unable to find this. Hopefully someone else out there has more information, but until then this should suffice.
    •    
  • Currently 4.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (12 votes cast)
 
[76,958 views]  

Recover from a 'Library is locked' iTunes error | 13 comments | Create New Account
Click here to return to the 'Recover from a 'Library is locked' iTunes error' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
This is the hard way
Authored by: Corsec on Jan 02, '03 12:18:41PM

If you read the error, the file is *locked* or you do not right *write permissions*. What you did was creat a copy that you owned and had write permissions to by default. If you just get into on bolt files, make sure you are the owner (the little (me) should be besides the name in the owner box) and same for group, and that owner could read write, group read, and others read No coping is needed. But bolth ways work :)



[ Reply to This | # ]
This is the hard way
Authored by: qdzlug on Jan 02, '03 04:22:11PM

Hi,

Thanks for responding - I just was looking into this a little more, and wanted to provide some clarification.

When the problem happened the permissions on the two files were 644 for both, and ownership was my account. The one thing I did not check (forgot to) was if the file was locked (in the getinfo screen from Finder).

I've been trying to recreate the problem (w/o the crashing the machine part ;> ) - I can check both the Unix permissions (via either finder or command line) and if the file is locked or not (via finder) and I don't notice a change at all from the default (644 and unlocked) when importing, playing, or burning.

You do raise a good point that should have been covered in the initial post - permissions/ownership should be checked on both files first. As an aside, have you encountered this problem where the permissions/ownership were off? I can't see why the app would need to change these.

The closest thing I can find at Apple's site is a bit that talks about the locking for a mailbox file, but I think (I don't use mail.app) that just creates a lock file in the spool directory.

Jason




[ Reply to This | # ]
This is the truth
Authored by: FACEMILK on Jan 09, '03 02:47:10AM

I had this exact problem just yesterday. I checked the files in question:
~/Music/iTunes
~/Music/iTunes/iTunes Music
~/Music/iTunes/iTunes 3 Music Library
~/Music/iTunes/iTunes Music Library.xml

All were UNlocked, owned by me, and I had read/write permissions.
A logout/login did not fix the problem.
A restart fixed it.



[ Reply to This | # ]
.xml file
Authored by: aranor on Jan 02, '03 03:28:51PM

I had that problem a while ago. I was copying a few hundred MP3s to my iTunes music library from my file server, and the server hard drive froze. iTunes just sat there, completely frozen. I force-quit it and when I opened it back up, the library was locked. Not knowing what else to do, I trashed the library file, went to iTunes, said import library, and selected the .xml file. Voila, after a few minutes of parsing the file, I had my library back.

But your way is probably better.



[ Reply to This | # ]
iTunes constantly re-locks my library
Authored by: cocoamix on Jan 25, '03 11:15:32AM

This still occasionally happens to me. It's infuriating! About once every month, when I try to quit iTunes, it freezes. I have to force quit it TWICE. The first one doesn't work, but the second one finally quits iTunes. When I try to run iTunes again, it tells me that the library is locked. When I try to trash the Library, it tells me that it's in use. After logging out and in, I it remains "in use" so I cannot trash it, so I sudo rm -fr it to finally get rid of it.
Process Viewer reveals nothing I could kill that's related to iTunes.

The ONLY sulution that works is restarting and re-importing all 2000 of my MP3's.
Using a new copy of iTunes, trashing all iTunes related prefs and files doesn't seem to help. It happens again in a few weeks. Even using a backup of my iTunes library does not work.

I'm SICK of this happening. Has anyone found a cause for why this is happening?



[ Reply to This | # ]
iTunes constantly re-locks my library
Authored by: JadeNB on Jun 10, '07 12:30:18PM

As a general matter, the command 'lsof' is a good way to find out what processes are using which files. (It can certainly be non-obvious.)



[ Reply to This | # ]
iTunes constantly re-locks my library
Authored by: morespace54 on Jun 11, '07 01:12:20PM

Good point.
As a reminder (and added suggestion to the previous post) you can also type (in Terminal):

[code]
lsof > ~/Documents/MyProcess.txt
[/code]

which will output the result in a text file named "MyProcess.txt" in your "Documents" folder...



[ Reply to This | # ]
Recover from a 'Library is locked' iTunes error
Authored by: faquin on May 03, '07 10:36:38AM

I love you guys, once again you saved me...
This tip still works with iTunes 7.1.1



[ Reply to This | # ]
Recover from a 'Library is locked' iTunes error
Authored by: Mangler on Jun 10, '07 12:40:42AM

Being as I keep my library on another computer, I have now been exposed to this problem twice as family will often shutdown the computer with the library while itunes is running on my PowerBook

Glad as I was to find this hint I was disappointed to find that all my play counts were reset - 3+ years of useless stats lost :(

I'm happy to be able to report this slightly quicker workaround:

1. Move your iTunes library Data file to your desktop.
2. Start iTunes - your play list will be empty
3. Quit iTunes and copy the data file from step 1 back in to the iTunes folder
4. Start iTunes

Problem gone and play history preserved!

Next time I get this issue, I'll simply try copying the file and then copying it back, i.e. skip step 2. Must be some attribute thing going on with the Data file which goes away once the thing is moved.

Hope this updated approach helps someone. Ciao from chilly olde New Zealand on a dark winters night.



[ Reply to This | # ]
Recover from a 'Library is locked' iTunes error
Authored by: Mangler on Jun 10, '07 12:43:34AM

Appols if this double posts as I was trying to reply to the original hint

I'm happy to be able to report this slightly quicker workaround:

1. Move your iTunes library Data file to your desktop.
2. Start iTunes - your play list will be empty
3. Quit iTunes and copy the data file from step 1 back in to the iTunes folder
4. Start iTunes

Problem gone and play history preserved!



[ Reply to This | # ]
Recover from a 'Library is locked' iTunes error
Authored by: itsluy on Oct 01, '09 11:33:13AM

Turns out all i had to do was uncheck "read only" from the file properties. Thanks for the tip though...



[ Reply to This | # ]
Recover from a 'Library is locked' iTunes error
Authored by: dimented1 on Sep 12, '10 01:10:11PM

I realize this post is old... from 2003 initially, right?

I have OS/X Leopard; iTunes 10.

I share an iTunes library with my wife's account. During this last upgrade, I started getting a 'Library is locked' error when starting iTunes on my account. I located the iTunes library file (the directory that holds all things iTunes) and viewed info on it. Then Iocated my account in the "Sharing & Permissions" section; I was there with "Read & Write" access. I clicked on the 'cog' wheel at the bottom of the iTunes info popup and selected "Apply to enclosed items".

That did the job for my account and now I can access iTunes once again. I'm not sure what that will do to my wife's account!



[ Reply to This | # ]
Recover from a 'Library is locked' iTunes error
Authored by: jeename on Nov 22, '10 07:02:31AM

I have tried but it had not worked,the only thing which worked is a small tool available at http://pathtoodeep.com



[ Reply to This | # ]