Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

About once per day, TextEdit starts showing dialogs like this when I try to open any file:

The document “test.txt” could not be opened. You don’t have permission.

To view or change permissions, select the item in the Finder and choose File > Get Info.

There's usually messages like this in system.log:

9/13/12 10:41:42.952 PM sandboxd[21081]: ([357]) TextEdit(357) deny file-read-data /Users/lauri/Desktop/test.txt
9/13/12 10:41:55.118 PM TextEdit[357]: NSFileVersion tried to tried to add a new generation and failed. Versioned file URL: file://localhost/Users/lauri/Notes/temp.txt, contents URL: file://localhost/Users/lauri/Notes/temp.txt.sb-de6477ff-BhVNrq, error: Error Domain=GSLibraryErrorDomain Code=1 "The operation couldn’t be completed. (GSLibraryErrorDomain error 1.)"
9/13/12 10:41:55.118 PM TextEdit[357]: NSDocument failed to preserve the old version of a document. Here's the error:
Error Domain=GSLibraryErrorDomain Code=1 "The operation couldn’t be completed. (GSLibraryErrorDomain error 1.)"
9/13/12 10:41:55.119 PM TextEdit[357]: <Document: 0x7f971d00a510>: An error occurred while attempting to preserve the backup file at file://localhost/Users/lauri/Notes/temp.txt.sb-de6477ff-BhVNrq: Error Domain=GSLibraryErrorDomain Code=1 "The operation couldn’t be completed. (GSLibraryErrorDomain error 1.)"

I can't open any files until I quit and reopen TextEdit. I also have to delete the backup files (like temp.txt.sb-de6477ff-BhVNrq) manually.

I've had the issue on two different installations. I have tried deleting the sandbox container and repairing permissions from the recovery partition. Does anyone know what's going on?

share|improve this question
    
Do you open the dame file in TextEdit and WriteRoom at the same time? –  Mark Jan 1 '13 at 20:48
    
Can you open terminal.app and tell us the output of ls -lt? –  paulgrav Jan 2 '13 at 7:36
    
@Mark Sometimes, but I don't think it starts because of that. I should probably try removing WriteRoom temporarily though. –  Lauri Ranta Jan 2 '13 at 14:56
    
@paulgrav The issue affects all files, and there's nothing unusual with my permissions (or the permissions of the files I've had open when it has started). –  Lauri Ranta Jan 2 '13 at 14:56
    
V strange. Still, probably wouldn’t do any harm to try to repair the user permissions. Might be some extended attributes causing issues. What OS X version are you running? Also, are there any sandbox errors in your logs? Your home directory isn’t hosted on a network mount, is it? –  paulgrav Jan 2 '13 at 15:37
show 4 more comments

3 Answers

Try repairing the user permissions.

http://www.ernieflores.net/mac-os-x-10-7-lion/repair-user-permissions-in-mac-os-x-lion/

In Lion, there is an additional Repair Permissions application utility hidden away. This tool is located inside boot Repair Utilities. Here’s how to access it.

  1. Restart Lion and hold down the Command and R keys.
  2. You will boot into the Repair Utilities screen. On top, in the Menu Bar click the Utilities item then select Terminal.
  3. In the Terminal window, type reset password and hit Return.
  4. The Password reset utility launches, but you’re not going to reset the password. Instead, click on the icon for your Mac’s hard drive at the top. From the drop-down below it, select the user account where you are having issues.
  5. At the bottom of the window, you’ll see an area labeled ‘Reset Home Directory Permissions and ACLs’. Click the Reset button there.

The reset process takes a couple of minutes. When it’s done, quit the programs you’ve opened and restart your Mac. Notice that ‘Spotlight’ starts re-indexing immediately

share|improve this answer
    
If the user permissions were messed up, wouldn't the application fail every time with the same error and not be able to create any new files? –  bmike Jan 2 '13 at 18:52
    
Maybe. Repairing user perms couldn’t hurt. –  paulgrav Jan 2 '13 at 20:05
    
It seems more a comment for something to try but not an actual answer to the question. We'll see based on the OP - I'm sure it's either been tried or can be ruled in/out in a short period of time. –  bmike Jan 2 '13 at 20:09
    
I tried it yesterday, but I'm getting those dialogs again, so it probably didn't help. –  Lauri Ranta Jan 4 '13 at 1:39
    
A permission error leads to reproducible access error. It isn't the case here. –  daniel Azuelos Jan 8 '13 at 20:04
add comment
up vote 1 down vote accepted

I ended up replacing TextEdit's code signature with an ad-hoc signature:

sudo codesign -f -s - /Applications/TextEdit.app/

It disables sandboxing, so for example the preference files are in ~/Library/Preferences/ instead of the sandbox container.

Edit: The dialogs returned after I reinstalled OS X, and now I'm getting errors like this for codesign -f -s -:

$ sudo codesign -f -s - /Applications/TextEdit.app/
/Applications/TextEdit.app/: replacing existing signature
/Applications/TextEdit.app/: object file format unrecognized, invalid, or unsuitable

I'm using https://github.com/jjgod/TextEditPlus for now. It's based on a version of TextEdit that came with 10.7, but it works with 10.8.2.

share|improve this answer
add comment

Possibly related http://forums.macrumors.com/showthread.php?t=798825.

Try deleting the ~/Library/Autosave Informations folder (it will be recreated automatically).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.