Gems can be used to extend or modify functionality in Ruby applications. Commonly they’re used to distribute reusable functionality that is shared with other Rubyists for use in their applications and libraries. Some gems provide command line utilities to help automate tasks and speed up your work.
The RubyGems software allows you to easily download, install and use Ruby software packages on your system. The software package is called a
gem and contains a packaged Ruby application or library.
If you don't have any RubyGems installed, there is still the pre-gem approach to getting software, doing it manually:
Download from RubyGems
Unpack into a directory and
ruby setup.rb (you may need admin/root privilege)
sudo ruby setup.rb
For more details and other options, see:
ruby setup.rb --help
Make sure you have ruby installed before installing rubygems, and then:
Installing RubyGems Using apt-get on Ubuntu
sudo apt-get install rubygems
Installing RubyGems Using yum
sudo yum install rubygems
Manual Installation Method
wget https://rubygems.org/rubygems/rubygems-2.6.6.tgz tar xvf rubygems-2.6.6.tgz cd rubygems-2.6.6 sudo ruby setup.rb
sudo apt-add-repository ppa:brightbox/ruby-ng
Enter to confirm
sudo apt-get update
Then you can install your ruby version of choice (the ppa supports
ruby2.3 and legacy versions
ruby1.9.1) Don't forget to include the respective
-dev package for your version. Otherwise the development of native extensions such as
mysql2 will fail.
sudo apt-get install ruby2.3 ruby2.3-dev ruby-switch
sudo ruby-switch set ruby2.3
>> ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
Now you can install any desired gem systemwide for all users via
sudo gem install gemname.
sudo gem install rails) but don't run
bundleas root. If it needs to install gems it will ask for the sudo password.
# list gem sources: gem sources -l # remove default gem source: gem sources -r https://rubygems.org/ # add other gem sources: gem sources -a https://ruby.taobao.org/