What are RubyGems

RubyGems is a convenient and powerful Ruby package manager. Ruby's third-party plug-ins are managed by gems, which are very easy to publish and share, and third-party extension libraries can be installed with a simple command. Features: Can install packages remotely, manage dependencies between packages, simple and reliable uninstallation, query mechanism, can query package information of local and remote servers, can maintain different versions of a package, web-based viewing interface, can view your Information about installed gems.

Install RubyGems

Official site  http://rubygems.org/pages/download

Download address: http://rubyforge.org/frs/?group_id=126

Windows users can directly download the .zip archive, decompress it, enter the directory where setup.rb is located from the CMD prompt window, and run ruby ​​setup.rb to install.

Ruby1.9.1 and later versions come with RubyGems, you can directly enter the command gem update --system in the CMD window to upgrade to the latest version.

How to install the gem package:

RubyGems.org is the official gem hosting center, where RubyGems remotely downloads gem packages. RubyGems installs all gem packages to the /[ruby root]/lib/ruby/gems/[ver]/ directory, which includes four directories: cache, doc, gems, specifications, and the downloaded native gem package is placed under the cache , the decompressed gem package is placed under gems. When you encounter problems during the installation process, you can enter these directories, manually delete the problematic gem package, and then re-run the gem install [gemname] command.

RubyGems command details:

Let's take the latest rubygems 1.8.16 as an example:

# View the version of RubyGems software
gem -v

# Update and upgrade the RubyGems software itself
gem update --system

# Update all installed gem packages
$ gem update

# Update the specified gem package
# Note: gem update [gemname] will not upgrade the old version of the package, you can use gem install [gemname] --version=[ver] instead of
$ gem update [gemname]

# To install the specified gem package, the program first finds the gem package from the local machine and installs it. If it is not available locally, install it from the remote gem.
gem install [gemname]

# Install the gem package only from the local machine
gem install -l [gemname]

# Install gem packages from remote only
gem install -r [gemname]

# Install gem packages, but do not install related documentation files
gem install [gemname] --no-ri --no-rdoc

# Install the specified version of the gem package
gem install [gemname] --version=[ver]

# Delete the specified gem package, note that this command will delete all installed versions
gem uninstall [gemname]

# Delete a specified version gem
gem uninstall [gemname] --version=[ver]

# View all gem packages installed on this machine
gem list

# 列出远程RubyGems.org 上有此关键字的gem包(可用正则表达式)
gem list -r keyword

# 列出远程RubyGems.org 上所有Gmes清单,并保存到文件。
gem list -r > remote_gem_list.txt

#查看所有gem包文档及资料
gem server 

#显示RubyGem使用帮助
gem help

#列出RubyGem命令一些使用范例
gem help example


更多命令请参考官方文档: http://guides.rubygems.org/command-reference/

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326646057&siteId=291194637