Archive for the ‘Linux’ Category

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.

Git Status in your Prompt

Came across a cool little Bash snippet today. Putting this in your .bashrc or .bash_profile files will – if your current directory is part of a git repository – show you your current branch and whether there are any uncommitted changes.

Note that the PS1 syntax used here is Debian-based (ie. Ubuntu). Other distros should use their own syntax.

UPDATE: changed it to append to PS1 instead of overwriting it, making it more cross-platform(-ish).

Passenger / Apache2 in Ubuntu

For the past few weeks, I’ve been teaching myself Ruby and Rails. Or rather, I’ve been trying to. I’ve been hitting snags when trying to actually set up my environment in my Ubuntu Server VM. Coming from a predominately PHP background, Rails (and Phusion Passenger in particular) are much more temperamental than I’m used to. I also prefer compiling my application stack myself from source as much as possible, while the Rails community seems to prefer installing packages.

(more…)