Tag: OSX

January 2012 Ruby on Rails Stack

Posted by – January 10, 2012

It seems like I am, entirely too frequently, setting up a new development environment for Ruby on Rails. Between the computers at work and at home I feel like I am starting over, from scratch, somewhere every 6 months or less. Whenever I make a substantial change to my development environment, I like to document it here for my own reference and in the hopes that it may help others.

This go around I am incorporating some recent additions to the stack, notably Homebrew and rbenv. These additions, as well as a few other changes are being made to simplify things and to follow the latest best practices.

The steps I followed to setup my development environment are as follows:

1. Install Homebrew – the missing package manager for OSX. Luckily I didn’t run into any issues installing Homebrew. Homebrew greatly simplifies installing some of the more difficult bits and pieces on OSX.

2. Install rbenv – This differs from my previous use of RVM. While I really liked RVM, the simplicity of rbenv convinced me to switch. Again, no real issues with installation (that is the beauty of a single purpose, simple tool). I didn’t use Homebrew to install rbenv, but in the future I will. With rbenv I also installed the companion ruby-build which simplifies the process of installing various Ruby versions.

3. Install PostgreSQL – While I am a longtime fan of MySQL, it’s acquisition by Oracle combined with the herd moving towards Postgres made me take the plunge. All in all it has been a fairly straightforward process. There is one caveat, when installing Postgres on OSX Lion (which replaced it’s bundled install of MySQL with Postgres) you need to make a minor change to the system paths so that Postgres loads from your installation and not the built in one. I followed the tips from a few blogs and updated /etc/paths, placing “/usr/local/bin” at the top. That one tip, combined with following the instructions provided by Homebrew (accessible via “brew info postgresql”) will get Postgres up an running in no time.

That is basically it! I think this is a really clean and simple install that makes my apps fairly portable. I am using Bundler to manage my Ruby Gems in conjunction with the rbenv-gemset plugin. I could just rely on Bundler, but I prefer to have the gems sandboxed in a separate gemset (for now).

After cloning from GitHub and running “bundle install” and the various rake database tasks I was up and running in development mode with relative ease. One of the wonders of the open source software community is that there seems to be a real emphasis on continuous and meaningful improvement. With each major iteration the tools I am using are becoming both more powerful and easier to use. I was able to get my development environment up and running in about an hour (less if my memory were better). That pales in comparison to some of the herculean efforts required in the past.

Ruby on Rails, Passenger & MySQL PATH issues in Snow Leopard

Posted by – September 8, 2009

I recently did a clean installation of Snow Leopard, which is great by the way, and I ran into some issues after installing MySQL and Ruby on Rails based on the instructions from Dan Benjamin at Hivelogic.

Specifically, when I would try to access a site in development mode I would get an error from Passenger that “Rails 2.3.4 could not be found”. I also noticed that on reboot my PATH wasn’t being loaded properly either so the system could not find MySql, Ruby, or RubyGems.

I tried placing the path information that, according to the instructions goes in ~/.profile into my ~/.bash_profile.

Now when I restart the system, MySQL and Ruby on Rail can be found! Passenger is working now as well. I am not sure if there was a change in the way Snow Leopard loads bash profiles or if there is just a problem with my installation that was preventing it from working when the PATH was specified in ~/.profile, but it’s all working now so hopefully this will help someone else.

Make OSX Terminal pretty

Posted by – August 31, 2009

I have always been annoyed with how a new tab opens in the OSX Terminal. I have my Terminal set to run “source ~/.bashrc” when the application starts. The problem with this is that it won’t run for new tabs, and I use lots of tabs (Rails development, web server, database, ruby console, etc…). And while I have been annoyed, it never really bothered me enough to look for a solution, until today.

As is usually the case, a quick search in Google led me to “Customizing the terminal prompt on Mac“. Apparently, OSX handles the terminal profiles a little differently than what I am used to. OSX uses profiles, where Ubuntu uses .bashrc. So, just add one line in your terminal profile to tell the terminal run the necessary command to load your .bashrc like so:

  1. First open up your ~/.bash_profile in your text editor of choice
  2. Add the line “source ~/.bashrc”
  3. Save and close ~/.bash_profile

Easy as can be! Now set your .bashrc to make your terminal as color-coded and informative as you want it to be. There are a lot of tutorials and information available for editing your .bashrc file.

Moving iTunes

Posted by – June 16, 2009

    I recently purchased a Drobo to move some of my larger multimedia files off of my iMac as it was running short on storage. The process for moving an iTunes library from one location to another can be daunting, so here are the steps I took. (Mac OSX specific).

    1. Copy files from drive A to drive B
    2. Make a backup of “iTunes Music Library.xml”
    3. Open “iTunes Music Library.xml” file on drive A in a text editor
    4. Find all references to drive A and replace with drive B
    5. Make a backup of the “iTunes Library” database file
    6. Delete the contents of the “iTunes Library” database file
    7. Open iTunes
    8. Get a beverage, it will take a while for iTunes to re-import your libraries xml file

    These steps were necessary because there are two accounts on my iMac using the same storage path for music but different iTunes libraries. Using the standard “Consolidate Library” method would have left me with thousands of duplicate song files. Using the above method simply changes where iTunes looks for the file to play.

Updating Ruby on OSX Leopard

Posted by – May 13, 2009

Quick and easy method for updating, or rather installing an updated version of Ruby on OSX Leopard (10.5) from Hivelogic. Ruby ships with OSX Leopard which is great, but the version included is outdated in regards to the recommendations of the Ruby on Rails folk.

This method seems to be the best way because it doesn’t overwrite what Apple has shipped with OSX, rather it just tells the computer to keep the older version, but use the newer version in it’s stead. Of course, this does require some command line shenanigans, but once you get started it really isn’t all that difficult. Besides, if you are concerned about using Ruby and/or Rails you should be comfortable using the command line!

Make Safari’s windows behave properly

Posted by – March 4, 2009

via: MacLife

I have not used Safari as my primary browser in OSX primarily because I prefer the tab behaviour of Firefox. This was true until I found this interesting article (See #4) on MacLife about changing the way Safari handles tabs.

Simply open up the Terminal and enter the following:

defaults write com.apple.Safari TargetedClicksCreateTabs -bool TRUE

This little gem tells Safari to open new windows in new tabs instead of in an entirely new window, just like Firefox does. Hopefully Apple will make this simpler in the future via an option in Safari’s Preferences, but until then I think this will suffice.

Now all I need Apple to do is to get auto-complete of URLs working like Firefox…

Secure Google Notifier

Posted by – July 15, 2007

Unbeknownst to most, your when you provide your user name and password to the Google Notifier for either Gmail or the Google Calendar you are transmitting those credentials in plain text. In order to secure your credentials, you need to configure the Google Notifier to transmit your credentials via secure http (https). To do, follow the directions in this article on macosxhints.com. I have discussed security in regards to Gmail before (see: “Secure your Gmail“), but that wasn’t necessarily in regards to the notifier.

While this may not seem all that important to you, just take a moment to consider how much of your personally identifiable information is transmitted through email. Without securing your credentials, you are inviting anyone to sniff your packets and pull any information that they want.

As far as I know, this little tip only works on the wonder-filled Mac OSX operating system.

Digital Nirvana

Posted by – November 1, 2006

As many of you know, I work in the IT field. The shop that I am in is all Microsoft, from the servers to the workstations. I recently became a Mac OSX convert as a result of my work with Ruby on Rails. I reached digital nirvana this evening when I was able to rather easily connect to my work’s network via our Cisco VPN and then remotely administer one of Windows servers using Microsoft’s Remote Desktop Connection for Mac OSX. This means that I don’t ever, ever, ever, ever need a Windows machine! Yay! (screenshot provided for the naysayers)

Screengrab