使用Rails的过程中你经常需要RubyGems(gem)工具来管理以及升级依赖的库(RubyGem)。RubyGem,就是一个个用Ruby语言编写的程序软件包,Rails就是一个最著名的RubyGem。RubyGems是标准的Ruby包管理器,它的功能类似于Linux下的apt-get。
我们来使用gem查看一下RailsInstaller已经安装好的gem包:
- E:\greensoft\RailsInstaller>gem list
- *** LOCAL GEMS ***
- actionmailer (3.2.1)
- actionpack (3.2.1)
- activemodel (3.2.1)
- activerecord (3.2.1)
- activerecord-sqlserver-adapter (3.2.1)
- activeresource (3.2.1)
- activesupport (3.2.1)
- arel (3.0.2)
- bigdecimal (1.1.0)
- builder (3.0.0)
- bundler (1.0.22)
- coffee-rails (3.2.2)
- coffee-script (2.2.0)
- coffee-script-source (1.2.0)
- erubis (2.7.0)
- execjs (1.3.0)
- hike (1.2.1)
- i18n (0.6.0)
- io-console (0.3)
- journey (1.0.3, 1.0.2)
- jquery-rails (2.0.1)
- json (1.6.5, 1.5.4)
- mail (2.4.4, 2.4.1)
- mime-types (1.18, 1.17.2)
- minitest (2.5.1)
- multi_json (1.1.0)
- mysql2 (0.3.11 x86-mingw32)
- pg (0.13.1 x86-mingw32)
- polyglot (0.3.3)
- rack (1.4.1)
- rack-cache (1.2, 1.1)
- rack-ssl (1.3.2)
- rack-test (0.6.1)
- rails (3.2.1)
- railties (3.2.1)
- rake (0.9.2.2)
- rb-readline (0.4.2)
- rdoc (3.12, 3.9.4)
- rubygems-update (1.8.19)
- rubyzip (0.9.6.1)
- sass (3.1.15)
- sass-rails (3.2.5)
- sprockets (2.1.2)
- sqlite3 (1.3.5 x86-mingw32)
- sqlite3-ruby (1.3.3)
- thor (0.14.6)
- tilt (1.3.3)
- tiny_tds (0.5.1 x86-mingw32)
- treetop (1.4.10)
- tzinfo (0.3.32, 0.3.31)
- uglifier (1.2.3)
将gem工具升级到最新版本:
- E:\greensoft\RailsInstaller>gem update --system
- Updating rubygems-update
- Fetching: rubygems-update-1.8.21.gem (100%)
- Successfully installed rubygems-update-1.8.21
- Installing RubyGems 1.8.21
- RubyGems 1.8.21 installed
- == 1.8.21 / 2012-03-22
- * 2 bug fixes:
- * Add workaround for buggy yaml output from 1.9.2
- * Force 1.9.1 to remove it's prelude code. Fixes #305
- ------------------------------------------------------------------------------
- RubyGems installed the following executables:
- E:/greensoft/RailsInstaller/Ruby1.9.3/bin/gem
- RubyGems system software updated
使用gem安装gem包:gem会访问internet,获取你希望安装的gem以及这个gem所依赖的其他gems。
- E:\greensoft\RailsInstaller>gem install rake
- Successfully installed rake-0.9.2.2
- 1 gem installed
- Installing ri documentation for rake-0.9.2.2...
- 活动代码页: 936
- Installing RDoc documentation for rake-0.9.2.2...
有关查看gem工具使用的更多信息:
- E:\greensoft\RailsInstaller>gem --help
- RubyGems is a sophisticated package manager for Ruby. This is a
- basic help message containing pointers to more information.
- Usage:
- gem -h/--help
- gem -v/--version
- gem command [arguments...] [options...]
- Examples:
- gem install rake
- gem list --local
- gem build package.gemspec
- gem help install
- Further help:
- gem help commands list all 'gem' commands
- gem help examples show some examples of usage
- gem help platforms show information about platforms
- gem help <COMMAND> show help on COMMAND
- (e.g. 'gem help install')
- gem server present a web page at
- http://localhost:8808/
- with info about installed gems
- Further information:
- http://rubygems.rubyforge.org
