How to install Ruby Gems
This article describes how to install Ruby gems on your account.
This article’s contents are limited to accounts without the Ruby Selector installed in cPanel. Look for the Setup Ruby App icon in the cPanel home screen’s Software area. In the event that the icon appears, read this article instead.
Installing Ruby gems
You can install gems using the gem command-line program. To do this, follow these steps:
- Log in to your account using SSH.
- To make sure you are in your home directory, type the following command at the command line:Copycd ~
- Use your preferred text editor to edit the .bash_profile file in your home directory. The .bash_profile file should contain the following configuration:
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # Set paths for Ruby gems: PATH=$HOME/ruby/gems/bin:$PATH GEM_HOME=$HOME/ruby GEM_PATH=$HOME/ruby/gems:/usr/lib/ruby/gems/1.8 export PATH GEM_HOME GEM_PATH # END - Save your changes to the .bash_profile file.
- To make the settings in the .bash_profile file take effect immediately, type the following command:
Copysource ~/.bash_profile - To create a directory for your local gems, type the following command:
Copymkdir -p ~/ruby/gems - Use your preferred text editor to create a .gemrc file in your home directory. The .gemrc file sets the GEM_PATH and GEM_HOME variables that are used by the gem program. The gemhome value is set to the full path where the gems will be installed (this is the directory that you created in step 6). The gempath values are set to the gemhome directory, as well as to the system-wide base gems directory. The following text shows an example .gemrc file. Replace username with your own Hostvento Hosting account username:
gemhome: /home/username/ruby/gems gempath: – /home/username/ruby/gems – /usr/lib/ruby/gems/1.8 - To verify that the gem environment has been updated, type the following command:
Copygem environmentThe output should display GEM PATHS with the values that you set in the .gemrc file. - To install a gem, type the following command. Replace gemname with the name of the gem that you want to install:
Copygem install gemnameFor example, to install the sass gem, type gem install sass.To uninstall a gem, type the following command:
Copygem uninstall gemname
Also Read
How to edit text files from the command line