Ruby RubyGems
Ruby's RubyGems is a package manager, which provides a distribution of Ruby programs and libraries of standard formats, but also provides a management tool package installed.
RubyGems gem tool designed to easily manage the installation, as well as for the distribution of gem server. This is similar to apt-get in Ubuntu, Centos of yum, Python's pip.
RubyGems about founded in November 2003, became part of the Ruby standard library from Ruby 1.9 version.
If your Ruby version is lower than 1.9, you can also manually install:
- First, download and install the package: https://rubygems.org/pages/download .
- Unzip and enter the directory, execute the command: ruby setup.rb
Update RubyGems command:
$ gem update --system # 需要管理员或root用户
Gem
Gem is a Ruby module (called the Gems) package manager. Which contains information about the package, as well as for the installation files.
Gem generally in the ".gemspec" build files, including documents related to the YAML Gem information. Ruby code can be established directly Gem, in this case generally use Rake to.
gem command
gem command is used to build, upload, download and install Gem package.
gem Usage
RubyGems functionally with apt-get, portage, yum and npm very similar.
installation:
gem install mygem
Uninstall:
gem uninstall mygem
Lists installed gem:
gem list --local
List of available gem, for example:
gem list --remote
Create RDoc document for all gems:
gem rdoc --all
Download a gem, but not installation:
gem fetch mygem
Search from the available gem, for example:
gem search STRING --remote
Construction of gem packages
gem command can also be used to build and maintain .gemspec and .gem files.
.gemspec Use file Build .gem:
gem build mygem.gemspec
Modify the domestic source
Since the domestic network reasons (you know), resulting rubygems.org stored in Amazon S3 above resource files intermittent connection failures.
So you will meet with gem install rack or bundle install time time to response, specifically with gem install rails -V to view the execution.
So we can modify it as Taobao Download Source: http://ruby.taobao.org/First, check the current source:
$ gem sources -l *** CURRENT SOURCES *** https://rubygems.org/
Next, remove https://rubygems.org/, and add Taobao Download Source http://ruby.taobao.org/.
$ gem sources --remove https://rubygems.org/ $ gem sources -a https://ruby.taobao.org/ $ gem sources -l *** CURRENT SOURCES *** https://ruby.taobao.org # 请确保只有 ruby.taobao.org $ gem install rails
If you use Gemfile and Bundle (for example: Rails project)
You can bundle the gem source code image command.
$ bundle config mirror.https://rubygems.org https://ruby.taobao.org
So you do not change your Gemfile the source.
source 'https://rubygems.org/' gem 'rails', '4.1.0' /en.