3

For some reason 2 of my files got locked and when I click the little lock icon in the upper right corner of the window it asks me if I would like to unlock, and doing so results in a "The file xxxx.h could not be unlocked" (Unlocking failed for an unknown reason). I have tried to restart Xcode, also tried to restart my machine with no help.

I am also unable to edit the files using BBEdit, I get the error "You do not have sufficient privileges to perform this operation (MacOS Error code: -5000)".

I'm running OS X Lion with Xcode 4.

Very strange as I have not made any changes to my system prior to this problem. Any help would be appreciated.

Ngoan Nguyen
  • 747
  • 2
  • 9
  • 19
  • Can you manually unlock the file in the Finder using Get Info? – Evan Mulawski Aug 21 '11 at 17:19
  • Yes, I am able to do that. I have set all the permissions to Read & Write for everyone for this particular file. I am also able to change the filename, but editing the contents results in this error. – Ngoan Nguyen Aug 21 '11 at 17:32
  • Try copying the file, deleting the original, and renaming the copy to match the original. – Evan Mulawski Aug 21 '11 at 17:33
  • I have also tried to restore to a time machine backup front before the problem, I have also tried to fix permissions on my drive. Time to do a complete restore? – Ngoan Nguyen Aug 21 '11 at 17:42

5 Answers5

6

Open the file in any text editor. If the contents isn't text based you'll see a lot of gibberish. Ignore this, copy the contents. Open up a new text file. Paste the contents and save over the old file. This will copy just the contents of the file and ignore permissions.

Peter Kazazes
  • 3,600
  • 7
  • 31
  • 60
  • Peter, thanks for the reply. I read this post too late. I just did a restore, going back to 10.6 as I get a lot of crashes with Xcode and 10.7. If it does not resolve the issue, I will try your method. – Ngoan Nguyen Aug 21 '11 at 19:16
  • 1
    Reformat didn't help, but Xcode 4 runs much better in 10.6 (for me). Anyway, pasting contents to new file worked perfectly. Thanks Peter for the answer. Any idea how this could have happened? – Ngoan Nguyen Aug 22 '11 at 00:11
  • @ngoan When you're copying the file like that, you're solely copying the *contents* rather than the metadata, which includes permissions and locking and what not. Fixes a lot of tricky situations. – Peter Kazazes Aug 22 '11 at 15:57
6

What you're dealing with here is an ACL issue. If you ls -l the directory you'll see a little + on the end of the permission string:

drwxr-xr-x+ 4 eekyou  staff  136 May  6  2011 eekyou.xcuserdatad

You can easily strip these off like so (in your project directory:

sudo chmod -R -E ./*

Hope this helps.

=]

eecue
  • 1,023
  • 9
  • 6
2

The @eecue answer didn't help me. I user another Terminal command for complete removal of all ACL permissions:

sudo chmod -RN ./*

Community
  • 1
  • 1
etolstoy
  • 1,798
  • 21
  • 33
0

First check if the file is opened/locked by another program or user.

If it is not, the program probably crashed and failed to remove the flag, lookup the file and check with CMD+i if it is locked.

If it is not, permissions are probably wrong, so check the permission in the CMD+i dialog at the bottom, and apply them to everything in the enclosing folder (a .xcproject is a directory).

If this still doesn't work (like for me), there is a simple command line to unlock all files in a folder. ONLY do this if all the above steps have been checked / taken.

sudo chflags -R nouchg /Users/username/Development/GIT/MyProject

Replacing the project folder with your own project folder of course.

Stijn
  • 858
  • 2
  • 12
  • 21
0

You may need to take ownership of the folder in which you wish to save your project. To do so, open up the console. Then type sudo chown $USER /path/to/your/project.