eddorre

Found 6 posts tagged with 'rvm'

Installing REE with rbenv with iconv support and Homebrew

December 28, 2011 — 0 Comments

I picked up a new Mac Mini recently and have been experimenting with rbenv instead of RVM. For some reason, one of my projects was giving me the following error when attempting to start the project (through the Rails console and through pow as well).

  
    ...action_controller/cgi_ext/stdinput.rb:14:in `included': undefined method `alias_method_chain' for CGI:Class (NoMethodError).
 

This error comes up when the Ruby version that you’re using isn’t compiled with iconv support. With rbenv, you can compile iconv support with the following command:

  
    CONFIGURE_OPTS="-c --with-iconv-dir=/usr/local/Cellar/libiconv/1.14" rbenv install ree-1.8.7-2011.03    
 

I should note that I lost quite a bit of time trying to target libiconv with version 1.13. I don’t know if this is a problem with libiconv 1.13 or it was something with my specific version, but once I upgraded to version 1.14, I was able to make it work.

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.

Installing Rails 3 (beta 4) Using RVM

June 20, 2010 — 12 Comments

I’ve been collecting Rails 3 links ever since the first beta hit but I’ve been putting off installing it because I’ve been terribly busy and some of the early problems that I was reading on Twitter (namely with Bundler) turned me off.

Yesterday, I finally had enough time to start the installation and documentation process. For those following this guide, I should warn you in advance, Rails 3 is a fast moving target. Stuff is changing all the time, so by the time that you come across this guide it might be out of date or not The Rails Way of doing things.

I’ll try to keep it updated as best I can, but keep that warning in mind.

One more thing, the following should work with *nixes, but for those curious, I’m using OS X — Snow Leopard.

Note: Don’t prefix sudo when installing or uninstalling gems into an rvm’d environment.

Let’s get started by installing RVM first. There are many ways to install RVM, but I chose the gem method.

sudo gem install rvm

Once the gem has been installed run the install process.

rvm-install

This should install and configure it for your shell (it did for me), but if it doesn’t, refer to the RVM install documentation for setting up your shell correctly.

I found that the gem version was a version behind the head version, so I updated it using:

rvm update --head

Followed by:

rvm reload

From some of the links that I’ve been reading, it’s been suggested that you install Ruby 1.9.2 for use with Rails 3. Using RVM, this is easy to do:

rvm install 1.9.2-head

Installing and compiling Ruby 1.9.2 takes a while.

Switch over to the 1.9.2-head version and let’s setup a Rails 3 gemset:

rvm --create use 1.9.2-head@rails3

Install the pre-release of Rails 3:

gem install rails --pre

If everything has gone well we should be able to see beta 3 when running the rails —version command:


rails --version
Rails 3.0.0.beta4

Note: If you get a rails/cli error here it’s possible that you already have another beta version installed from somewhere. You can uninstall the previous beta gems, but it’s probably easier to just clean your gems instead:

gem clean

Note: This will only clean the gems in your rvm’d environment. It won’t affect any other Ruby/RubyGems install.

Since I use RSpec for my testing framework, I installed those gems:


gem install rspec --prerelease
gem install rspec-rails --prerelease

At this point, Rails should be installed and waiting for you to create a new project using:

rails new [path/project_name]

If you don’t specify a -d option to the rails command then it’ll use SQLite as the database, but you can always using the database of your choice:

rails new [path/project_name] -d mysql|postgres|sqlite3

Once you’ve created a project open it up in your editor of choice and familiarize yourself with the Gemfile file.

You should pay attention to the :require directive on gems. Sometimes the gem name and the library name aren’t the same. For example, here is the aws-s3 gem with its require line:

# gem 'aws-s3', :require => 'aws/s3'

If you want to install Rails Edge then comment out or delete the line from the Gemfile:

gem 'rails', '3.0.0.beta4'

And uncomment the line:

# gem 'rails', :git => 'git://github.com/rails/rails.git'

If you’re having weird issues with Rails 4, upgrading to Edge might be the way to go. I know that it fixes and error in a form bypassing validation in Rails3Beta2, so it might be worth it.

You should also note the database gem that’s listed in your Gemfile. In a simple project that I created it was listed as:

gem 'sqlite3-ruby', :require => 'sqlite3'

Since I installed RSpec and RSpec Rails, I should tell Bundler about them. Note that I’m only installing them in the test environment.

I added the following to the bottom of the Gemfile:


group :test do
  gem 'rspec', '>= 2.0.0.beta.12'
  gem 'rspec-rails', '>= 2.0.0.beta.12'
end

After you’ve edited your Gemfile to your liking, install them with Bundler:

bundle install

Once all of the gems have been installed, you should have a working Rails application that you can test by running:

rails server

If everything has gone according to plan you should have a working Rails3Beta4 app running.

Using Ruby Enterprise Edition and Passenger on OS X with RVM

July 21, 2010 — 6 Comments

Ever since I installed Ruby 1.9.2-head with RVM (Ruby Version Manager) I’ve become a convert of using it to manage all of my Ruby installs.

Last week I decided to install Ruby Enterprise Edition on my development environment as my default Ruby install. My motivation for this was two-fold; better memory management and a comment by Laurent Sansonetti (one of the authors of MacRuby and works at Apple) on an article written by Robby Russell titled Installing Ruby on Rails, Passenger, PostgreSQL, MySQL, Oh My Zsh on Show Leopard, Fourth Edition.

The comment left by Laurent suggested not to rename the default Ruby install (and then symlinkling the Ruby installed via Ports) but to manage it by setting the load path.

Using RVM, we can install any Ruby version we want and have it set as the default Ruby instance easily. Let’s see how it’s done.

Note: The following documentation worked on my install of OS X. When encountering an error with the following instructions refer to the RVM documentation.

Installing the RVM Gem

There are multiple ways to install RVM, but I chose the gem install method (even if it is listed as not recommended in the documentation).


sudo gem install rvm

Installing RVM and Adding Hooks to Your Shell (bash, zsh, etc.)

Once the gem has been installed, you can now run the rvm-install command to add the hooks to your shell by running the following:


rvm-install

After RVM has been installed, you’ll be prompted to change something in your shell profile (the end of the install process will provide you with a code snippet). Since I’m using Oh My Zsh, and therefore the z shell (zsh), I opened up my .zshrc file located at /Users/carlos/.zshrc and pasted the code snippet at the bottom of the file.

Here is an example (the code snippet might be different depending on your shell and the version of RVM that was installed):


if [[ -s /Users/carlos/.rvm/scripts/rvm ]] ; then source /Users/carlos/.rvm/scripts/rvm ; fi

Updating RVM to the Latest Version

The gem version of RVM seems to be a little behind (this may be why it’s not recommended) so we’re going to update it. This updates RVM to the latest, greatest version.


rvm update --head

Installing Ruby Enterprise Edition and Dependencies

As the title of this post suggests, we’re going to be installing Ruby Enterprise Edition. According the web site, using Ruby Enterprise Edition has the potential to reduce Ruby memory consumption by 33% (on average) when used in combination with Phusion Passenger.

Before we can start installing Ruby Enterprise Edition we need to install Readline.


rvm package install readline

Once that’s done, we’re ready to get to the main event; installing Ruby Enterprise Edition.


rvm install ree -C --with-readline-dir=$HOME/.rvm/[yourusername]

Usually it will take some time for Ruby to be downloaded, compiled and properly installed with RubyGems support. When that’s done, you can switch over to your new RVM Ruby interpreter:


rvm use ree

Installing RubyCocoa for Use with the Passenger Preference Pane

Passenger is easiest to administer with the Passenger Preference Pane but it has some dependencies that we’ll have to install in order for it to work. If you don’t wish to manage virtual hosts with the Passenger Preference Pane, you can skip down to the next section.

Installing RubyCocoa

At the time of this writing, RubyCocoa 1.0.1 has been released but it’s broken at this time so we’ll have to rely on RubyCocoa 1.0.0.

Let’s download this from source and build it:


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
sudo ruby install.rb install

To make sure that RubyCocoa you’ll need to pop open an IRB session:


irb
require 'osx/cocoa'

If everything has gone well, you’ll see the shell return ‘true’ and you’re ready to install the Passenger Preference Pane

Installing and Configuring Passenger

Note: If you already had a development environment up and running, you’ll need to re-install your gems into the new RVM’d environment. When installing a gem into an RVM’d environment, do not prepend the command with sudo.

Before we can install Passenger, we’ll need to generate some wrapper scripts. This is done with the following:


rvm ree --passenger

Since the Ruby Enterprise Edition suggests using it with Passenger, we’ll go ahead and install the gem now.


gem install passenger

Once the gem has been installed, we need to to make sure that Apache is running; open up the System Preferences and then the Sharing applet. Make sure that Web Sharing is checked. Doing so will start the Apache web server.

Since Apache has been installed we need to have Passenger and Apache be friends. Start off by adding the Passenger module to Apache:


rvmsudo passenger-install-apache2-module

Towards the end of the installation process, you’ll be prompted to copy some information to put into your Passenger configuration file. There is a catch though, the Passenger install has no idea that you’re using RVM so the last two lines have inaccurate information (they are most likely referencing your system Ruby instance). The fix for this is easy though, you’ll just have to change the references to point to your RVM’d instance instead.

Here is an example from my install (obviously you’ll want to replace [yourusername] with your actual username:


LoadModule passenger_module /Users/[yourusername]/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /Users/[yourusername]/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11
PassengerRuby /Users/[yourusername]/.rvm/bin/passenger_ruby

As mentioned, the above code snippet needs to be added to a passenger configuration file which I normally put in /private/etc/apache2/other and I call the file passenger.conf. I should note that this directory is owned by root, so when you create the file and save it you’ll have to provide your system password in order to make the changes.

Here is a sample of my configuration file:


LoadModule passenger_module /Users/carlos/.rvm/gems/ree-1.8.7-2010.02/gems/passenger-2.2.14/ext/apache2/mod_passenger.so
PassengerRoot /Users/carlos/.rvm/gems/ree-1.8.7-2010.02/gems/passenger-2.2.14
PassengerRuby /Users/carlos/.rvm/bin/passenger_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
</Directory>

Finishing Up

If you’d like to make Ruby Enterprise Edition your default Ruby Interpreter, just use the following command:


rvm ree --default

Once Passenger has been configured, all that’s left to do is restart Apache. You can restart Apache by going to the System Preferences Pane and selecting the Sharing applet. Uncheck and re-check Web Sharing.

You should now be able to add Rails and Rack applications with the Passenger Preference Pane. Note: When opening the Passenger Preference Pane, you might see this warning:

Passenger Preference Pane 32bit Warning

This is normal if you have a 64-bit machine. Since RubyCocoa is 32-bit, it just has to relaunch the preference pane.

RVM is a fast moving target and as such these installation instructions may be out of date by the time you read them. I try to update my older posts when I get new information, but if you stumble across something that doesn’t work or if you know of a better way of doing something, please let me know.

Installing Rails 3 (beta 3)

April 18, 2010 — 6 Comments

This article contains outdated information. Please refer to the new article.

I’ve been collecting Rails 3 links ever since the first beta hit but I’ve been putting off installing it because I’ve been terribly busy and some of the early problems that I was reading on Twitter (namely with Bundler) turned me off.

Yesterday, I finally had enough time to start the installation and documentation process. For those following this guide, I should warn you in advance, Rails 3 is a fast moving target. Stuff is changing all the time, so by the time that you come across this guide it might be out of date or not The Rails Way of doing things.

I’ll try to keep it updated as best I can, but keep that warning in mind.

One more thing, the following should work with *nixes, but for those curious, I’m using OS X — Snow Leopard.

Note: Don’t prefix sudo when installing or uninstalling gems into an rvm’d environment.

Let’s get started by installing RVM first. There are many ways to install RVM, but I chose the gem method.

sudo gem install rvm

Once the gem has been installed run the install process.

rvm-install

This should install and configure it for your shell (it did for me), but if it doesn’t, refer to the RVM install documentation for setting up your shell correctly.

I found that the gem version was a version behind the head version, so I updated it using:

rvm update --head

Followed by:

rvm reload

From some of the links that I’ve been reading, it’s been suggested that you install Ruby 1.9.2 for use with Rails 3. Using RVM, this is easy to do:

rvm install 1.9.2-head

Installing and compiling Ruby 1.9.2 takes a while.

Switch over to the 1.9.2-head version and let’s setup a Rails 3 gemset:

rvm --create use 1.9.2-head@rails3

Instead of installing a bunch of gems manually, we can use a gemset to do it for us.

curl -L http://rvm.beginrescueend.com/gemsets/rails3b3.gems -o rails3b3.gems

Once that has been downloaded, let’s import the gemset file:

rvm gemset import rails3b3.gems

If everything has gone well we should be able to see beta 3 when running the rails —version command:


rails --version
Rails 3.0.0.beta3

Note: If you get a rails/cli error here it’s possible that you already have another beta version installed from somewhere. This popped up a couple of times for me. The first time it happened, I uninstalled all gems named rails and re-installed the rails3b3 gemset. This took care of it but it came back, it’s probably easier to just clean your gems instead:

gem clean

Note: This will only clean the gems in your rvm’d environment. It won’t affect any other Ruby/RubyGems install.

Since I use RSpec for my testing framework, I installed those gems:


gem install rspec --prerelease
gem install rspec-rails --prerelease

At this point, Rails should be installed and waiting for you to create a new project using:

rails [path/project_name]

If you don’t specify a -d option to the rails command then it’ll use SQLite as the database, but you can always using the database of your choice:

rails [path/project_name] -d mysql|postgres|sqlite3

Once you’ve created a project open it up in your editor of choice and familiarize yourself with the Gemfile file.

You should pay attention to the :require directive on gems. Sometimes the gem name and the library name aren’t the same. For example, here is the aws-s3 gem with its require line:

# gem 'aws-s3', :require => 'aws/s3'

If you want to install Rails Edge then comment out or delete the line from the Gemfile:

gem 'rails', '3.0.0.beta3'

And uncomment the line:

# gem 'rails', :git => 'git://github.com/rails/rails.git'

If you’re having weird issues with Rails 3, upgrading to Edge might be the way to go. I know that it fixes and error in a form bypassing validation in Rails3Beta2, so it might be worth it.

You should also note the database gem that’s listed in your Gemfile. In a simple project that I created it was listed as:

gem 'sqlite3-ruby', :require => 'sqlite3'

Since I installed RSpec and RSpec Rails, I should tell Bundler about them. Note that I’m only installing them in the test environment.

I added the following to the bottom of the Gemfile:


group :test do
  gem 'rspec', '>= 2.0.0.beta.7'
  gem 'rspec-rails', '>= 2.0.0.beta.7'
end

After you’ve edited your Gemfile to your liking, install them with Bundler:

bundle install

Once all of the gems have been installed, you should have a working Rails application that you can test by running:

rails server

If everything has gone according to plan you should have a working Rails3Beta3 app running.