eddorre

Found 4 posts tagged with 'mac os x'

Rails Ultimate Install Guide on OS X Lion (using RVM, Homebrew, and Pow)

July 21, 2011 — 43 Comments

Apple has released their latest version of OS X, Lion, and with that, it’s time for me to update my install guides. I’ve been running the GM Seed of Lion since it was released and I’ve only encountered minor issues along with way with my current Rails development environment.

If you’ve read any of my guides before, you’ll notice that in this guide I’ve switched from using Passenger to using 37Signals’ Pow Rack server. I’ve found that when I upgraded from Snow Leopard, Passenger and Apache stopped serving requests. Both services didn’t have records of requests coming and there were no errors messages recorded. Since trying Pow, I’ve become a convert. It’s dead simple to install and get running.

With that being said, there are some caveats with Pow. First, it hijacks port 80. So if you’re developing other sites using PHP and Apache, there is some extra work for you ahead. Additionally, there is an open and outstanding issue where the server will go haywire and start monopolizing the CPU time. For me, these issues are minor (I just stop the process if it goes haywire – it’ll automatically restart itself) and I don’t develop in PHP.

Now that I’ve gotten that out of the way, let’s dive in shall we?

Installing Xcode

Whether you’re upgrading Snow Leopard or you have a fresh install of Lion ready to go, the first thing that you’ll need to do is install Xcode. It’s free and available at the Mac App Store.

One thing of note, unlike other applications from the Mac App Store, downloading it doesn’t mean installing it. Once downloaded you’ll have to run the Install Xcode application to get it installed.

Installing Homebrew

Homebrew is a package manager that allows you to install all sorts of Open Source goodies on your Mac with a simple command. If you’re upgrading from Snow Leopard and you already had Homebrew installed, my experience has been that you don’t need to do anything different.

If you’re on a fresh install though, you can install Homebrew with the following command.


ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

Follow the instructions provided by Homebrew to complete the installation.

Installing Git

Pretty much every Rails hacker out there uses Git, so let’s grab that using Homebrew. Again, if you already had Git installed using Homebrew on Snow Leopard, you won’t need to do anything new here.

  
    brew install git
 

Optional Install: wget and oh-my-zsh

The following is completely optional, but I recommend them. By default, OS X uses the bash shell when interacting with the terminal, but that’s not the only shell available. I prefer zsh myself and for my install process, I use Robby Russell’s oh-my-zsh. It’s easiest to install oh-my-zsh with wget, so we’ll install that first. If you’ve upgraded, you won’t need to do anything new for zsh to continue working.

  
    brew install wget
 

Once wget is installed, installing oh-my-zsh is easy.

  
    wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh 
 

Follow any prompt by the install script to complete installation. Closing and re-opening your terminal should launch zsh from now on. To check run this command:

  
    ps -p $$
 

You should see zsh instead of bash. If you don’t, you can switch your shell manually be running the change shell command.

  
    chsh -s /bin/zsh
 

Installing RVM

Although OS X comes with a version of Ruby, it’s somewhat out of date. We can work around the issue by installing RVM.

  
    bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
 

Follow any prompts from the RVM install process to complete the installation. One of the final install steps for RVM is automatically loading into a shell session. You should follow the latest install step but for my copy and paste purposes those are:

  
        [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
 

Close the shell and restart it in order to have RVM loaded.

NOTE: When I upgraded, I was having an issue with Passenger, and I thought that my RVM install might be the culprit. So I removed RVM completely and simple re-installed it according the these instructions.

If you want to remove RVM complete run the following command:

  
    rvm implode
 

Installing a Ruby Interpreter

Since I have Rails applications that I work on that still haven’t been migrated to Ruby 1.9.2, I use Ruby Enterprise Edition as my baseline Ruby install.

Optional Install: IConv Package

If you use the Nokogiri gem, you’ll probably need this package in order for it to compile.

  
    rvm pkg install iconv
 
Installing Ruby Enterprise Edition

I’m not sure if the CC line is still necessary with the final release of Xcode 4, but with the GM seed and earlier versions of Lion, it wouldn’t work without it.

  
    CC=/usr/bin/gcc-4.2 rvm install ree --enable-shared
 

If you installed the IConv package then the install command is:

  
     CC=/usr/bin/gcc-4.2 rvm install ree --enable-shared --with-iconv-dir=$rvm_path/usr    
 

Installing a Ruby interpreter will take a while as it has to download and compile it.

As I said before, I use REE as my base Ruby install so when it’s installed, I’ll set it as my default.

  
    rvm --default use ree
 
Optional Install: Ruby 1.9.2

Although my base Ruby install is REE. I usually use Ruby 1.9.2 for any new Rails 3 applications. Installing is simple:

  
    rvm install 1.9.2
 

Installing Database Servers

Although SQLite works for most smaller projects, MySQL and PostgreSQL are usually needed for larger projects. Installing them is easy with Homebrew. If you’re upgrading from Snow Leopard, you don’t need to do anything different with your database servers.

Installing MySQL

  
    brew install mysql
 

Make sure that you follow the instructions at the end to complete the installation and setup. You can review the post install instructions at any time by using the Homebrew info command.

  
    brew info mysql
 

Installing PostgreSQL

  
    brew install postgres
 

Again, make sure that you follow the instructions at the end to complete the installation and setup. As with MySQL, you can review the post install instructions at any time by using the Homebrew info command.

  
    brew info postgres
 

Installing Base Gems

One of the cool things about RVM is that you can create gemsets. These allow you to compartmentalize your Ruby gem installs. By default, RVM creates one global gemset that others will inherit from. In this gemset, I usually apply some base gems that I want across all projects. A full treatise on gemsets is beyond the scope of this guide so I urge you to read the RVM documentation for more information.

  
    gem install bundler
    gem install capistrano
    gem install capistrano-ext
    gem install git_remote_branch
    gem install open_gem
    gem install heroku
    gem install powder
 

The powder gem gives you a nice wrapper on some of the Pow commands.

Installing Pow

Installing Pow is simple, just run this command in your terminal and enter your password when prompted.

  
    curl get.pow.cx | sh
 

You can review the install script listed here, if you’re concerned about running command in your shell to automatically install things on your system:

http://get.pow.cx/

All you need to do to get up and running is navigate to your project’s directory in the terminal and run the following command (assuming you installed the powder gem):

  
    powder
 

If the application is a Rails 2.3 application, it’ll prompt you to generate a base config.ru file. For my applications, I just followed the defaults.

Your web application should be available at http://mywebapplication.dev where “mywebapplication” is the name of the directory where your project lives. If there are underscores in the directory name, use hyphens in the URL.

This should be all that you need to get your projects running on the new version of OS X. Happy coding!

Rails Ultimate Install Guide on OS X Snow Leopard (using RVM, Homebrew, and Passenger)

April 09, 2011 — 13 Comments

I’ve written numerous guides over the years on installing Ruby on Rails on Snow Leopard. This is an amalgamation of that knowledge and experience. It’s also my last guide that I’ll write for Snow Leopard now that OS X Lion is on the horizon.

Let’s jump right in.

Installing XCode

This whole process breaks down if you don’t install XCode, so we’ll do that now. You can use the XCode that came with your install DVD or download it online.

Installing Homebrew

I used to use MacPorts as my package manager but I’ve recently switched over to using Homebrew. Installing Homebrew is easy since OS X comes with a version of Ruby pre-installed.


ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"

Follow the instructions provided by Homebrew to complete the installation.

Installing Git

Pretty much every Rails hacker out there uses Git, so let’s grab that using Homebrew.


brew install git

Optional Install: wget and oh-my-zsh

The following is completely optional, but I recommend them. By default, OS X uses the bash shell when interacting with the terminal, but that’s not the only shell available. I prefer zsh myself and for my install process, I use Robby Russell’s oh-my-zsh. It’s easiest to install oh-my-zsh with wget, so we’ll install that first.


brew install wget

Once wget is installed, installing oh-my-zsh is easy.


wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

Follow any prompt by the install script to complete installation. Closing and re-opening your terminal should launch zsh from now on. To check run this command:


ps -p $$

You should see zsh instead of bash. If you don’t you can switch your shell manually by running the change shell command.


chsh -s /bin/zsh

Installing RVM

Although OS X comes with a version of Ruby, it’s sorely out of date. We can work around this issue by installing RVM.

If you’ve opted not to install oh-my-zsh, then replace zsh with bash in the command below.


zsh < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Follow any prompts from the RVM install process to complete the installation. One of the final install steps for RVM is automatically loading into a shell session. You should follow the latest install step but for my copy and paste purposes those are:

  
    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
 

Close the shell and restart it in order to have RVM loaded.

Installing a Ruby Interpreter

Since I have Rails applications that I work on that still haven’t been migrated to Ruby 1.9.2, I use Ruby Enterprise Edition as my baseline Ruby install.

Install the Readline package

I’ve always installed the Readline package with my Ruby REE install, so let’s do that now.

  
    rvm pkg install readline
 
Optional Install: IConv Package

One of our projects is using the spreadsheet Ruby gem and that requires the IConv RVM package.

  
    rvm pkg install iconv
 
Installing Ruby Enterprise Edition
  
    rvm install ree --enable-shared --with-readline-dir=$HOME/.rvm/usr --patch readline-fix --with-iconv-dir=$rvm_path/usr
 

Obviously, you’ll want to discard the IConv argument if you didn’t install the RVM package. Installing a Ruby interpreter will take a while as it has to download and compile it.

As I said before, I use REE as my base Ruby install so when it’s installed, I’ll set it as my default.

  
    rvm --default use ree
 
Optional Install: Ruby 1.9.2

Although my base Ruby install is REE, I usually use Ruby 1.9.2 for any new Rails 3 applications.

  
    rvm install 1.9.2
 

Installing Database Servers

Although SQLite works for most smaller projects, MySQL and PostgreSQL are usually needed for larger projects. Installing them is easy with Homebrew.

Installing MySQL

  
    brew install mysql
 

Make sure that you follow the instructions at the end to complete the installation and setup. You can review the post install instructions at any time by using the Homebrew info command.

  
    brew info mysql
 

Installing PostgreSQL

  
    brew install postgres
 

Again, make sure that you follow the instructions at the end to complete the installation and setup. As with MySQL, you can review the post install instructions at any time by using the Homebrew info command.

  
    brew info postgres
 

Installing Base Gems

One of the cool things about RVM is that you can create gemsets. These allow you to compartmentalize your Ruby gem installs. By default, RVM creates one global gemset that others will inherit from. In this gemset, I usually apply some base gems that I want across all projects. I also install the Passenger gem at this stage. A full treatise on gemsets is beyond the scope of this guide so I urge you to read the RVM documentation for more information.

  
    gem install bundler
    gem install capistrano
    gem install capistrano-ext
    gem install git_remote_branch
    gem install open_gem
    gem install heroku
    gem install passenger
 

Installing Passenger Apache Module

Before we install Passenger, we have to update the RVM wrapper scripts. I’m not sure why installing a new instance from the Internet doesn’t include everything we need, but Passenger usually complains at the end of the install process if you haven’t done it.

  
    rvm get head && rvm reload && rvm repair all
 

Once that’s completed, finish setting up the module.

  
    passenger-install-apache2-module
 

At the end of the install process, you’ll need to let Apache know that it needs to load the module. I do this by creating a passenger.conf and pasting the code lines from the install instructions.

  
    sudo touch /private/etc/apache2/other/passenger.conf
 

You’ll need to use sudo because that directory is owned by root and you won’t be able to modify it with your account. Open the newly created file with your favorite text editor and paste in the code at the end of the install instructions. Your config file should look something similar to this:

  
    LoadModule passenger_module /Users/carlos/.rvm/gems/ree-1.8.7-2010.02@global/gems/passenger-3.0.1/ext/apache2/mod_passenger.so
    PassengerRoot /Users/carlos/.rvm/gems/ree-1.8.7-2010.02@global/gems/passenger-3.0.1
    PassengerRuby /Users/carlos/.rvm/wrappers/ree-1.8.7-2010.02@global/ruby

    # Set the default environment to development
    RailsEnv development

    # Which directory do you want Apache to be able to look into for projects?
    <Directory "/Users/carlos/work">
      Order allow,deny
      Allow from all
      Options -MultiViews
    </Directory>
 

Installing RubyCocoa and the Passenger Preference Pane

Although it’s quite old, I still use the Passenger Preference Pane for managing Rails and Rack apps. The current version requires RubyCocoa so we’ll need to install that first.

Installing RubyCocoa

  
    cd ~/
    wget http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.0/RubyCocoa-1.0.0.tar.gz/download
    tar xzf RubyCocoa-1.0.0.tar.gz && rm RubyCocoa-1.0.0.tar.gz && cd RubyCocoa-1.0.0
    ruby install.rb config --build-universal=yes
    ruby install.rb setup
    # have to sudo to install this because the installer wants to copy example stuff out of the /System dir
    sudo ruby install.rb install
    cd ~/
    rm -rf ~/RubyCocoa-1.0.0
 

Once RubyCocoa has been installed, you can download the Passenger Preference Pane.

Optional Install: Pow!!

Recently, 37Signals released a zero-configuration Rack server for Mac OS X called Pow!!. This removes the need for Passenger, RubyCocoa and the Passenger Preference Pane. This project is still very young as of this writing and I haven’t had a chance to try it myself, but if you’re feeling up it, to the installation instructions and the documentation are quite good.

Standardizing Next and Previous Tab Commands in OS X

January 25, 2009 — 0 Comments

I use a lot of tabbed applications. OS X’s Terminal, Safari and Firefox come to mind. Each of these applications have a keyboard shortcut for moving between tabs; COMMAND+SHIFT+] to move forward and COMMAND+SHIFT+[ to move backwards.

There are some apps that don’t conform to this standard; Adium, Propane, and TextMate and it drives me nuts. Why can’t they all be standard? Well, actually they can using OS X to override the application specific command.

Below are some instructions and a screenshot of how to do this.

  • In order to do this first open up the System Preferences applet and click on Keyboard & Mouse.
  • Scroll down and select Application Keyboard Shortcuts
  • Click the + button
  • Select your application from the Application menu
  • Type in the menu title of the shortcut (for example, to move forward a tab in TextMate it’s Next File Tab
  • Type in the shortcut in the shortcut field and click Add

Mac OS X Keyboard System Preferences

Leopard: A Face Only a Mother Could Love - Part I

November 15, 2007 — 0 Comments

The first time that I used Mac OS X Tiger, I was in love. Coming from the Windows XP and Vista world, the interface seemed like such a breath of fresh air. Yes, it does have eye candy elements but it didn’t seem gaudy.

Last night, I finally sat down to install Leopard on my iMac. Honestly, I haven’t had much play time on it so I don’t know all of the ins and outs of the Operating System but after a day of using it my initial impression is, “Wow, it’s just so…ugly.”

Whereas Tiger seemed timeless and classy, Leopard looks cheap and forgettable. Here are some of the problem spots:

The Dock

Although the “glass” reflective surface doesn’t bother me as much as it does some people, I think the little “glow” lights underneath it that denote which programs are currently running is completely unusable. Look at the difference between the Leopard Dock and the Tiger Dock.

Tiger:

Tiger Dock

Leopard:

Leopard Dock

You can remove the glassy shelf from the dock by using the following commands at the terminal:

  • defaults write com.apple.dock no-glass -boolean YES
  • killall Dock

Also, one can get the triangles back by reading the article Leopard Dock with black triangle

The Folders

The folder icons from Tiger have changed from a 3/4 perspective view to a front perspective. Although a regular folder is easily recognizable, system folders and docked folders lose contrast when compared to their Tiger brothers.

Consider the following folders.

Tiger:

Tiger Folders

Leopard:

Leopard Folders

The difference is striking. At a glance, the Tiger icons are clearly different from each other giving meaning to the icons. The Leopard icons lose this contrast and easily become lost within each other. It’s hard to tell if there is anything special about these icons at all. This is especially true for those users that do not have the best eyesight.

In the next article I’ll cover the huge drop shadow and that dang highlight color.