Ruby 1.9.3 on Mac OS X Lion with XCode 4.3

I wanted to install rails 3.2.4 on Mac OS 10.7. The system ruby is 1.8, but I wanted to run against 1.9.3, and it was tricky getting everything working with XCode 4.3.

I wanted to use RVM, but right now RVM spits out an error telling you that 1.9.3 is kind of covered with XCode 4.3, that prior versions of ruby aren’t supported with 4.3, and that you might want to install OSX-GCC-Installer and remove XCode. If you want to go down that path, the OSX-GCC dude seems like a nice bloke: http://kennethreitz.com/xcode-gcc-and-homebrew.html

I didn’t! As such, I decided to see if homebrew would install ruby 1.9.3 (it does) and how hard it would be to switch between its version of ruby and the system ruby (it’s trivial).

  • Remove rvm if you’ve installed it:
    rm -Rf ~/.rvm
  • Install XCode 4.3 from the app store.
    Once installed, open XCode -> Preferences -> Downloads -> Command Line Tools. Download ’em.
  • Install HomeBrew: http://mxcl.github.com/homebrew/. Do your best with their post-install instructions. I especially found it useful to uninstall macports http://guide.macports.org/chunked/installing.macports.uninstalling.html
  • Install ruby 1.9.3: brew install ruby
  • Open .profile (or .bashrc or whatever bash config file you’re using) and add
    PREPATH=$PATH
    #homebrew suggests putting usr/local/bin before /usr/bin
    export PATH=/usr/local/bin:$HOME/.gems/bin:$PATH
    alias unbrew="export PATH=${PREPATH}"
    

    Now, if you want to use the system ruby you run unbrew from the command line

Advertisements

Sharing one iTunes library amongst multiple users on Mac OS X

Last night, I set up iTunes so that it uses one library for all my accounts on my mac, and figured to do a little writeup.

Let’s say you have an account, jam, and want it to use the iTunes library from the account bees. I assume you’ve already got bees’ iTunes stuff set up how you like.

There are two key insights:
a) both accounts are, by default, part of the staff group
b) your iTunes library is, at its heart, just a folder on the file system

In jam:

1. Open a console
2. cd ~/Music
3. remove the iTunes folder and ln -s ~bees/Music/iTunes .

That’s the initial, basic setup done. If you open iTunes, though, you’ll find that you can’t write to anything from the jam account, so you can’t actually do useful things, like opening iTunes.

However! From the jam account, open a Terminal and:

su - bees

Now, in the bees terminal:

cd ~/Music/iTunes
ls -l

Now, the owner of each file is bees:staff, right? And bees has the correct permission for writing everywhere, right? So, use chmod to replicate the user permissions to the group permissions for every folder, and for your library files and whatnot:

-rwxrwx---@  1 bees  staff    806136  1 Aug  2008 Temp File.tmp
-rw-rw-r--@  1 bees  staff   4628440 17 Oct 08:32 iTunes Library
-rw-rw-r--   1 bees  staff   1122304 17 Oct 08:31 iTunes Library Extras.itdb
-rw-rw-r--   1 bees  staff  83341312 13 Oct 15:50 iTunes Library Genius.itdb
drwxrwx---  69 bees  staff      2346 16 Oct 12:17 iTunes Music/
-rwxrwxr-x@  1 bees  staff  22701215 16 Oct 13:22 iTunes Music Library.xml
-rwxrwx---@  1 bees  staff         8 17 Oct 08:31 sentinel

Now, cd iTunes\ Music/ and do the same trick here, then cd into Music and Podcasts and those guys and do the same trick there.

Of course, it’s directories which need their permissions changing, not files, so if you want to you can always find ./ -type d -exec chmod 775 {} \; from the iTunes directory if you want to be quick about the majority of this. After that, go find the files which need their permissions changing too, like the iTunes library xml file, and you’re rockin’ and rollin’.