TextMate extended attributes corrupting files
My development setup right now is a VirtualBox Ubuntu Server x64 guest running on OS X Snow Leopard. I use the VBox shared folder feature to share the document root of the sites I'm working on from OS X to Ubuntu, and edit the files natively using TextMate on OS X. This setup has worked very well for me, as I can emulate the server environment my apps will eventually deploy to (as well as reap the benefits of Ubuntu's much-superior-to-Apple's command line). I have no need to buy any third-party ssh-mounting software; it is a completely turnkey solution.
Except for one minor flaw: TextMate saves files with extended file attributes - basically arbitrary metadata associated with an individual file. The vboxsf filesystem with which you must mount shared folders in the guest OS does not support extended attributes. This results in a basically corrupted file.
You can see if a file has these attributes by performing a long listing in a directory:
jlindsey-mbp:javascripts jlindsey$ ls -l total 160 -rw-r--r-- 1 jlindsey staff 19145 Nov 24 10:53 jquery-ui.js -rw-r--r-- 1 jlindsey staff 57254 Nov 24 10:53 jquery.js -rw-r--r--@ 1 jlindsey staff 1204 Nov 24 11:33 messages-table.js
Note the "@" symbol after the permissions for messages-table.js. This indicates that it has extended attributes associated with it:
jlindsey-mbp:javascripts jlindsey$ xattr -l messages-table.js com.macromates.caret: { column = 31; line = 24; }
Thankfully, the fix is simple. Simply close TextMate and run this command:
defaults write com.macromates.textmate OakDocumentDisableFSMetaData 1
If you have any files that are still corrupted, opening them and re-saving them in TextMate will not clear the attributes. To do this, you can either open them with an editor (such as vim) in the guest OS and save them again, or in OS X run this command:
xattr -d com.macromates.caret messages-table.js
Substituting of course your file name, which will delete the named attribute.
(Cross-posted from my personal blog for your enjoyment: TextMate extended attributes corrupting files) - Link no longer exists