RubyGems is a package manager for Ruby that provides a standard format for distributing Ruby programs and libraries, as well as a tool for managing package installations.
RubyGems is designed to easily manage
gem
the tools that are installed,and for distribution
gem
the server. This is similar to apt-get under Ubuntu, Centos
yum
, Python’s
pip
.
RubyGems was founded around November 2003 and has been part of the Ruby standard library since Ruby version 1.9.
If your Ruby is lower than version 1.9, you can also install it manually:
First download the installation package: https://rubygems.org/pages/download .
Extract and enter the directory, execute the command: ruby setup.rb
Update
RubyGems
command:
$ gem update --system # Administrator or root user required
6.46.1. Gem #
Gem is the package manager for the Ruby module (called Gems). It contains package information, as well as files for installation.
Gem is usually built on the “.gemspec” file, which contains a YAML file with information about Gem. Ruby code can also build Gem directly, which is usually done using Rake.
6.46.2. Gem command #
gem
commands are used to build, upload, download, and install Gem packages.
6.46.3. Gem usage #
RubyGems is functionally very similar to apt-get, portage, yum, and npm.
Installation:
gem install mygem
Uninstall:
gem uninstall mygem
List what has been installed
gem
:
gem list --local
List what is available
gem
, for example:
gem list --remote
For all
gems
create an RDoc document:
gem rdoc --all
Download one
gem
, but do not install:
gem fetch mygem
From the available
gem
search in, for example:
gem search STRING --remote
6.46.4. Construction of gem package #
gem
commands are also used to build and maintain
.gemspec
and
.gem
files.
Utilization
.gemspec
file construction
.gem
:
gem build mygem.gemspec
6.46.5. Modify domestic sources #
Due to domestic network reasons (you know), the intermittent connection of the resource files stored in rubygems.org on Amazon S3 failed.
So you will meet with
gem
install
rack
or
bundle
install
when there is no response for half a day, you can use the
gem
install
rails
-V
to view the execution process.
So we can modify it to the domestic download source: https://gems.ruby-china.com