English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
RubyGems is a package manager for Ruby, providing a standard format for distributing Ruby programs and libraries, as well as a tool for managing package installations.
RubyGems is a tool designed to easily manage gem installations and servers used for distributing gems, similar to apt under Ubuntu.-get, Centos's yum, Python's pip.
RubyGems was approximately created in2003year11month, from Ruby 1.9version it became part of the Ruby standard library.
If your Ruby is below 1.9 version, or you can install manually:
Firstly, download the installation package:https://rubygems.org/pages/download。
Unzip and enter the directory, then execute the command:ruby setup.rb
Update RubyGems commands:
$ gem update --system # Requires administrator or root user
Gems are the package manager for Ruby modules (called Gems). It contains package information and files used for installation.
Gems are usually built according to the '.gemspec' file, which is a YAML file containing information about Gems. Ruby code can also be used to directly build Gems, in which case Rake is usually used.
The gem command is used to build, upload, download, and install Gem packages.
RubyGems is functionally similar to apt-get, portage, yum, and npm are very similar.
Install:
gem install mygem
Uninstall:
gem uninstall mygem
List installed gems:
gem list --local
List available gems, for example:
gem list --remote
Create RDoc documents for all gems:
gem rdoc --all
Download a gem without installing:
gem fetch mygem
Search from available gems, for example:
gem search STRING --remote
The gem command is also used to build and maintain .gemspec and .gem files.
Use the .gemspec file to build .gem:
gem build mygem.gemspec
Due to domestic network reasons (you know), rubygems.org is stored on Amazon S3 The resource files above may fail to connect intermittently.
So you may encounter gem install rack or bundle install without any response for half a day, you can use gem install rails specifically. -V to view the execution process.
Therefore, we can modify it to a domestic download source: https://gems.ruby-china.com
Firstly, check the current source:
$ gem sources -l *** CURRENT SOURCES *** https://rubygems.org/
接着,移除 https://rubygems.org/,并添加国内下载源 https://gems.ruby-china.com/。
$ gem sources --remove https://rubygems.org/ $ gem sources -a https://gems.ruby-china.com/ $ gem sources -l *** CURRENT SOURCES *** https://gems.ruby-china.com/ # 请确保只有 gems.ruby-china.com $ gem install rails
你可以用bundle的gem源代码镜像命令。
$ bundle config mirror.https://rubygems.org https://gems.ruby-china.com/
这样你不用改你的 Gemfile 的 source。
source 'https://rubygems.org/' gem 'rails', '4.1.0' ...