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:
sudo gem updatesudo gem install rails (accept all the dependencies)rails /my/complete/path/to/railsappThat’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.
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
More info on the “Gems Manuals Page”: http://docs.rubygems.org/read/chapter/4#page16
Use at own risk:
gem update -s http://gems.rubyonrails.com
_Note: -s didn’t work for me, try this:
gem update --source http://gems.rubyonrails.com
instead_
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:
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.
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.
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):
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 resetfrom the command line.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. 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. For more information on troubleshooting Windows XP networking issues, see Microsoft KB article How to troubleshoot TCP/IP connectivity with Windows XP