How to Install Gems From Command Line in Ruby
Gems are a type of plug-in for the Ruby programming language. Gems can help you integrate with a third-party service via its API, or Application Programming Interface, which lets you interact with data on systems such as Twitter and Facebook. It can provide out-of-the-box functionality for a number of features and can provide additional extensions to the base Ruby language. You can install a new gem straight from the command line on any system that has Ruby installed. The gem installation command first looks for gem files stored locally on your machine. If it cannot find such a gem, it pulls from the Internet gem repository automatically.
Instructions
-
-
1
Click "Start" and type "cmd" without the quotation marks to launch the command line application in Windows. Click the "Terminal" application to open the command line on a Mac.
-
2
Type "cd directory"--replacing "directory" with the directory you want to switch to if the gem file you want to install is located on your computer.
-
-
3
Type the the following command: "gem install gemname" and replace "gemname" with the exact name of the gem you want to install.
-
4
Press "Enter." The installer locates the gem on your computer or, if it is not on your computer, looks for and downloads a gem with that name from the Internet gem repository. The gem is now installed on your machine.
-
1
Tips & Warnings
Find the exact name of the gem you want to install by consulting that gem's page on RubyGems.org.
If you're working with Ruby on Rails, use Bundler to install gems.
Make sure you type the name of the gem correctly. If you mistype the gem name, the installer will not be able to locate it to install it.