How to install your own Ruby Gems
From A2Wiki
You can now install Ruby Gems through cPanel. Login to your cPanel account, and click the "Ruby Gems" icon that is located in the Software/Services section.
The following instructions are still valid if you would like to do it through shell.
Environment Setup
1.
Shell into your account. See our Knowledgebase article at http://a2hosting.com/kb/ssh for instructions.
2.
Run the following command to make sure you're in your home directory:
cd ~
3.
Find out where the base gems are installed by running:
gem environment
You should see something like this:
RubyGems Environment:
- VERSION: 0.9.2 (0.9.2)
- INSTALLATION DIRECTORY: /usr/lib64/ruby/gems/1.8
- GEM PATH:
- /usr/lib64/ruby/gems/1.8
- REMOTE SOURCES:
- http://gems.rubyforge.org
Note the value for INSTALLATION DIRECTORY.
4. Create a directory to install local gems:
mkdir gems
5. Create a .gemrc file in your home directory. This is where the GEM_PATH and GEM_HOME variables will be set for use by the gem program. Create the .gemrc file with the following command:
vi ~/.gemrc
When you're done, the .gemrc file should look like this:
gemhome: /home/username/gems gempath: - /home/username/gems - /usr/lib/ruby/gems/1.8
Where the value for gemhome is set to the full path where you'll install your gems (the directory that you created in step 4). The values for gempath should be set to the directory specified for gemhome as well as the base gems directory (from step 3). 'username' should be replaced with your username.
6.
Verify that the gem environment has been properly updated by running
gem environment
Rails Setup for Local Gems
1.
For each of your Rails apps that will use your local gems, you'll need to set GEM_PATH in your config/environment.rb file so that Rails knows where to find your gems. Edit config/enviornment.rb:
vi /path/to/your/railsapp/config/environment.rb
Add this line:
ENV['GEM_PATH'] = '/home/username/gems:/usr/lib/ruby/gems/1.8'
'/home/username/gems' should be replaced with the full path to your local gems directory and '/usr/lib/ruby/gems/1.8' should be replaced with the base gem installation directory from step 3 of the previous section.
2.
Add GEM_PATH and GEM_HOME to your shell enviornment:
vi ~/.bash_profile
Add the following lines:
export GEM_PATH=/home/username/gems:/usr/lib/ruby/gems/1.8 export GEM_HOME=/home/username/gems
'/home/username/gems' should be replaced with your local gems directory and '/usr/lib/ruby/gems/1.8' should be replaced with the base gem installation directory.
.bash_profile will be read on your next login and set GEM_HOME and GEM_PATH automatically. To set these variables without logging out and logging back in, simply run each line as a command.
