8

I received an email with a plain text attachment (named 'noname') via Gmail and downloaded it using Chrome from gmail.com. It's a recurring automated report. Everyday I get the file , download it, open it, read it, and enjoy my life. Some days like today I get the file, download it and TextEdit on OS X won't let me open it.

TextEdit reports "The document "noname.txt" could not be opened. You don't have permissions."

A Get Info in Finder shows permissions:

ram (Me) Read & Write
Staff Read only
Everyone Read only

From a terminal I can do whatever I want to it (read, write, rename...). An ls -l shows:
-rw-r--r--@ 1 ram staff

An ls -le shows the same (i.e, no ACLs shown).

What gives?

5
  • Three unrelated questions: Have you considered hard-disk failure? Have you tried opening it with vi in a Terminal? Are there extended attributes on the downloaded file (quarantine or so)?
    – Frizlab
    Commented Oct 13, 2013 at 16:43
  • Sorry didn't see the "@". What are the extended attributes on the file, then?
    – Frizlab
    Commented Oct 13, 2013 at 16:50
  • The file is a plain text file created by running a script script that outputs plain-text and piping it into mail
    – Ram
    Commented Oct 14, 2013 at 1:34
  • com.apple.metadata:kMDItemWhereFroms 316Bcom.apple.quarantine 71B
    – Ram
    Commented Oct 14, 2013 at 1:35
  • Disk Utility doesn't report any problems. Everything from the terminal, vi included, works without a hitch.
    – Ram
    Commented Oct 14, 2013 at 1:36

3 Answers 3

5

From debugging a different problem (which showed up as deny file-read-data in the Console, see the other answer), it seems that sandboxd prevents sandboxed applications from reading quarantined data, so I think you'd need to remove the attribute with: xattr -d com.apple.quarantine /path/to/file (see for instance https://superuser.com/a/28394/46794). You'd need to prefix the command with sudo if the file didn't belong to your user, but according to your info it does.

The other user reported that using a non-sandboxed application fixed the problem, and this would confirm that sandboxing is at fault.

An aside: When ls reports extended attributes with @ next to the permission field, you don't need ls -le file, but instead ls -l@ file.

2
  • Thanks for the ls -l@ catch. I totally got that wrong and as a result didn't see the attributes that clarified and confirmed answers suggesting quarantine. All the affected files have, since some update (from Apple?), been tagged with com.apple.quarantine.
    – Ram
    Commented Jan 21, 2014 at 19:48
  • 2
    IIUC, applications downloading from the Internet are encouraged to tag the downloaded files as quarantined, so that the user is warned when he/she opens them by double-clicking. The mechanism is apparently in place since OS X 10.5, so maybe Chrome was updated to use it. One API to do that is described here: ilostmynotes.blogspot.de/2012/06/…, which points to developer.apple.com/library/ios/documentation/general/Reference/… for some official docs. Commented Jan 22, 2014 at 1:24
0

I'm not sure if this is the same problem I had, but every now and then TextEdit (and not any other application) started showing a dialog like this when I tried 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 were 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/test.txt, contents URL: file://localhost/Users/lauri/Notes/test.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/test.txt.sb-de6477ff-BhVNrq: Error Domain=GSLibraryErrorDomain Code=1 "The operation couldn’t be completed. (GSLibraryErrorDomain error 1.)"

I was able to open files normally after quitting and reopening TextEdit.

I haven't seen those dialogs after I replaced TextEdit with TextEditPlus, which is basically a non-sandboxed fork of TextEdit.

-2

Quit, don't just close, but Quit TextEdit. When TextEdit starts again it will "remember" who you are.

When Text Edit has the Main Menu Cmd-Q or Main Menu / TextEdit / Quit or Right Click on the TaskEdit dock icon and choose Quit.

You must log in to answer this question.

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