Ruby on Rails
GemRails (Version #52)

The preferred method of installing Rails is through the packaging scheme RubyGems that makes it really easy to install libraries and keep them up to date. Here’s how you install Rails using RubyGems:

  1. Get hold of RubyGems 0.8.1 ":http://rubyforge.org/frs/?group_id=126 (or higher)
  2. sudo gem update
  3. sudo gem install rails (accept all the dependencies)
  4. rails /my/complete/path/to/railsapp

That’s it! When new versions of Active Record and Action Pack are released, you just do gem update, and you’ll have the new versions available to your app.

Note You may have to run sudo ruby setup.rb before gem install rails if you have compiled from source.

Note: If you want to run EdgeRails using the bleeding versions from SVN, then you should pick the regular set of Rails as a file.
_Note: Debian users should check out RailsOnDebian.

Windows Gem Install Hanging? On some versions of Windows, the remote Rails installation via Gems may simply hang. While various issues can cause this behavior, in our case, we managed to work around this behavior by seperately installing each item in the Manual Installation section below. Gems was even able to access the necessary remote installation files over TCP.

Tying your app to a specific set of library versions

Go to config/environment.rb where you can tie Rails to specific versions like this (this will lock your app to 0.12.1 or newer:

require_gem 'activesupport', '>= 1.0.4'
require_gem 'activerecord', '>= 1.10.1'
require_gem 'actionpack', '>= 1.8.1'
require_gem 'actionmailer', '>= 0.9.1'
require_gem 'actionwebservice', '>=0.7.1'
'= x.y.z' to keep it at a single version
'>= x.y.z' to use that version or newer
'<= x.y.z' to use that version or older
$ gem dependency rails 

will show you what versions of each library correspond to a specific version of rails

More info on the “Gems Manuals Page”: http://docs.rubygems.org/read/chapter/4#page16

Running beta gems.

Use at own risk:

gem update -s http://gems.rubyonrails.com
_Note: -s didn’t work for me, try this:

<pre> ==gem update --source <a href="http://gems.rubyonrails.com">http://gems.rubyonrails.com</a>== </pre>

instead_

Running gem install when you are behind a proxy.

Set the HTTP_PROXY environment variable.

Note this is fully qualified, as such:
http_proxy=http://URL:PORT

http_proxy=http://127.0.0.1:5865
in this example, the proxy is running on the localhost. With NTLM authorization to get through a corporate firewall.

NB: This may not work if you are behind a Microsoft ISA Proxy server with only NTLM (MS ISA Server proprietary) authentication available. If this is the case, you can try the Microsoft Firewall Client or the Python NTLM Authorization Proxy Server.

JB: A gem is available which gives ruby the ability to authenticate with ISA natively. To use it with gems follow these steps:

  1. Download rubysspi from the Ruby Win32 SSPI project page(also available as gem install rubysspi but that doesn’t help much, does it?)
  2. Install the gem locally
  3. Copy spa.rb from the gem install to your site-ruby directory
  4. Find gem.cmd in your ruby bin directory and add “-rspa” to the command line.
  5. Set http_proxy environment variable as above
  6. gem list rails

Zanbowser (07.31.2007:16.05EST): I had some success with the method above; however, it bears mentioning, the process for editing the “gem.cmd” file. From a comment in “spa.rb,” edit the file like so:

@"ruby" -rspa "c:\ruby\bin\gem" %1 %2 %3 %4 %5 %6 %7 %8 %9

Not entirely sure if you need all the %[variable] declarations in there, but this worked for me, all the same.

Forcing install of specific version

If for some reason you need to install an older version of Rails, or you think that “gem install rails” isn’t installing all of the Rails components, you can force-install a specific version as follows:

gem install rails -v 0.13.1

The ‘-v’ flag indicates you’re specifying a version — in this case, version 0.13.1.

Manual installation (if all else fails…).

If gem install rails still refuses to connect for some reason, perhaps because you are “firewalled out” somehow, rails can be installed by installing the following gems manually, in this order (assuming you already have Ruby successfully installed):

  1. Activesupport
  2. Actionpack
  3. Actionmailer
  4. Activerecord
  5. Actionwebservice (for rails <= 1.2.X)
  6. Activeresource (for rails >= 1.2.5, 2.0)
  7. Rake
  8. Rails

To install manually, download the .gem files from the above links, place them in a local directory, then issue the gem install gemname command from this directory for each gem in order.

Of course, you will then have to continue downloading and updating each of these gems manually if you wish to stay current.

Another fix if you are having problems installing from behind a firewall is to run

netsh winsocket reset
from the command line. Beware that this will effectively remove and reinstall the TCP/IP stack on your computer, so if you have special settings configured, you should read more before trying this.

This also helped to fix a problem of mine where I was able to install it the hard way (from above) but webbrick would not run. (Note: For more information on troubleshooting Windows XP networking issues, see >TCP/IP connectivity with Windows XP )

The preferred method of installing Rails is through the packaging scheme RubyGems that makes it really easy to install libraries and keep them up to date. Here’s how you install Rails using RubyGems:

  1. Get hold of RubyGems 0.8.1 ":http://rubyforge.org/frs/?group_id=126 (or higher)
  2. sudo gem update
  3. sudo gem install rails (accept all the dependencies)
  4. rails /my/complete/path/to/railsapp

That’s it! When new versions of Active Record and Action Pack are released, you just do gem update, and you’ll have the new versions available to your app.

Note You may have to run sudo ruby setup.rb before gem install rails if you have compiled from source.

Note: If you want to run EdgeRails using the bleeding versions from SVN, then you should pick the regular set of Rails as a file.
_Note: Debian users should check out RailsOnDebian.

Windows Gem Install Hanging? On some versions of Windows, the remote Rails installation via Gems may simply hang. While various issues can cause this behavior, in our case, we managed to work around this behavior by seperately installing each item in the Manual Installation section below. Gems was even able to access the necessary remote installation files over TCP.

Tying your app to a specific set of library versions

Go to config/environment.rb where you can tie Rails to specific versions like this (this will lock your app to 0.12.1 or newer:

require_gem 'activesupport', '>= 1.0.4'
require_gem 'activerecord', '>= 1.10.1'
require_gem 'actionpack', '>= 1.8.1'
require_gem 'actionmailer', '>= 0.9.1'
require_gem 'actionwebservice', '>=0.7.1'
'= x.y.z' to keep it at a single version
'>= x.y.z' to use that version or newer
'<= x.y.z' to use that version or older
$ gem dependency rails 

will show you what versions of each library correspond to a specific version of rails

More info on the “Gems Manuals Page”: http://docs.rubygems.org/read/chapter/4#page16

Running beta gems.

Use at own risk:

gem update -s http://gems.rubyonrails.com
_Note: -s didn’t work for me, try this:

<pre> ==gem update --source <a href="http://gems.rubyonrails.com">http://gems.rubyonrails.com</a>== </pre>

instead_

Running gem install when you are behind a proxy.

Set the HTTP_PROXY environment variable.

Note this is fully qualified, as such:
http_proxy=http://URL:PORT

http_proxy=http://127.0.0.1:5865
in this example, the proxy is running on the localhost. With NTLM authorization to get through a corporate firewall.

NB: This may not work if you are behind a Microsoft ISA Proxy server with only NTLM (MS ISA Server proprietary) authentication available. If this is the case, you can try the Microsoft Firewall Client or the Python NTLM Authorization Proxy Server.

JB: A gem is available which gives ruby the ability to authenticate with ISA natively. To use it with gems follow these steps:

  1. Download rubysspi from the Ruby Win32 SSPI project page(also available as gem install rubysspi but that doesn’t help much, does it?)
  2. Install the gem locally
  3. Copy spa.rb from the gem install to your site-ruby directory
  4. Find gem.cmd in your ruby bin directory and add “-rspa” to the command line.
  5. Set http_proxy environment variable as above
  6. gem list rails

Zanbowser (07.31.2007:16.05EST): I had some success with the method above; however, it bears mentioning, the process for editing the “gem.cmd” file. From a comment in “spa.rb,” edit the file like so:

@"ruby" -rspa "c:\ruby\bin\gem" %1 %2 %3 %4 %5 %6 %7 %8 %9

Not entirely sure if you need all the %[variable] declarations in there, but this worked for me, all the same.

Forcing install of specific version

If for some reason you need to install an older version of Rails, or you think that “gem install rails” isn’t installing all of the Rails components, you can force-install a specific version as follows:

gem install rails -v 0.13.1

The ‘-v’ flag indicates you’re specifying a version — in this case, version 0.13.1.

Manual installation (if all else fails…).

If gem install rails still refuses to connect for some reason, perhaps because you are “firewalled out” somehow, rails can be installed by installing the following gems manually, in this order (assuming you already have Ruby successfully installed):

  1. Activesupport
  2. Actionpack
  3. Actionmailer
  4. Activerecord
  5. Actionwebservice (for rails <= 1.2.X)
  6. Activeresource (for rails >= 1.2.5, 2.0)
  7. Rake
  8. Rails

To install manually, download the .gem files from the above links, place them in a local directory, then issue the gem install gemname command from this directory for each gem in order.

Of course, you will then have to continue downloading and updating each of these gems manually if you wish to stay current.

Another fix if you are having problems installing from behind a firewall is to run

netsh winsocket reset
from the command line. Beware that this will effectively remove and reinstall the TCP/IP stack on your computer, so if you have special settings configured, you should read more before trying this.

This also helped to fix a problem of mine where I was able to install it the hard way (from above) but webbrick would not run. (Note: For more information on troubleshooting Windows XP networking issues, see >TCP/IP connectivity with Windows XP )