8

I some application, such as Xcode, Pages and Pixelmator 2, when I save, I get an error about not having the permissions to save the file:

"The document “[document name]” could not be saved. You don’t have permission. To view or change permissions, select the item in the Finder and choose File > Get Info."

There's nothing wrong with the permissions. I can edit and save the same files from other applications, such as Textmate, Text Edit and Preview, without problems. I can also create a new project in Xcode, and it generates all the files without problem, but I still get the error message when trying to save any changes in these.

I'm running Lion, clean installed.

Edit: here's an example ls -l on some files I can't edit:

-rw-r--r--  1 ulrikdamm  staff  4221 Nov  1 08:36 french.strings
-rw-r--r--  1 ulrikdamm  staff  3755 Nov  1 10:53 german.strings
-rwxrwxrwx  1 ulrikdamm  staff  4147 Oct 31 23:49 hungarian.strings

even with full permissions, I can't save them. And it's not only some files that cannot be saved, it's all files, no matter what their permission level is.

Edit 2: folder permissions:

drwx------+ 32 ulrikdamm  staff  1088 Nov  4 14:00 Desktop

(yes, it's on my desktop)

id output:

uid=501(ulrikdamm) gid=20(staff) groups=20(staff),402(com.apple.sharepoint.group.1),401(com.apple.access_screensharing),12(everyone),33(_appstore),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),100(_lpoperator),204(_developer)

Edit 3: I tried making a new user, and saving files there works without problems. Can it has something to do with some user settings being messed up?

5
  • Can you add the permissions of the directory the files are in? And run id in Terminal?
    – nohillside
    Commented Nov 4, 2011 at 13:35
  • Have you tried to fix permissions from DiskUtility?
    – Eir Nym
    Commented Nov 4, 2011 at 13:53
  • yes, multiple times. Commented Nov 4, 2011 at 14:01
  • How did you restore your data after the clean Lion install?
    – nohillside
    Commented Nov 4, 2011 at 18:00
  • I manually moved the files. But it worked for a long time, the error suddenly came. Commented Nov 6, 2011 at 0:09

2 Answers 2

2

Since you haven't used ls -le as recommended, we don't know what the access control list looks like, but there might be something going on there that is preventing you from being able to write the files. The fact that a newly created user CAN edit the files makes me even more suspicious.

This command will remove ALL access control list entries from the folder and all its subfolders and files:

sudo chmod -RN path/to/folder/containing/files

Once you've cleared the access control list, try resetting the ownership like so:

sudo chown -R ulrikdamn:staff path/to/folder/containing/files

Now grant permissions like so:

sudo chmod -R u+rwX,g+rX,o+rX path/to/folder/containing/files

This gives you full read/write permissions. The "staff" group and all other users get full read permissions. Using an uppercase X, sets the execute bit for all directories within the tree, but leaves the execute bit for regular files as is.

Lowercase x would set the execute bit for all folders AND files. The execute bit must be set for a directory in order to read its contents. If you'd like to give write permissions to the group or others, switch out for g+rwX or o+rwX as necessary in the last command.

Here I'm passing in a folder path. If you want to pass in a single file, just remove the -R from each command. The R makes the command recursive, applying it to an entire directory tree. Without it, the command will modify the permissions for a single file or folder passed in.

1

It might be just an ownership issue with some of your files. To fix run

sudo chown $USER:staff ~/

in Terminal to change the ownership of all files and folders in your home folder to yourself.

1
  • 3
    Explaining what the command do would be nice. Commented May 22, 2012 at 12:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .