博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
about rubygems install
阅读量:6246 次
发布时间:2019-06-22

本文共 4646 字,大约阅读时间需要 15 分钟。

3. Installing RubyGems

Get it from   ([url]http://rubyforge.org/frs/?group_id=126[/url]) and run (as root, if appropriate and necessary)
ruby setup.rb
It’s easy. It installs the required library files and the 
gem command. This command gives us the power to do everything else in this document, except distribute gems (for now!).
Debian Linux: Debian does not automatically include all the standard Ruby libararies in the basic Ruby package. As a result, you may need to ’’apt-get’’ libyaml-ruby and libzlib-ruby before you can install rubygems.

If a user does not have access to the standard installation location (typically 
/usr/local/lib/ruby), then they have the option of installing RubyGems in a alternate location.
Note that if you can’t install RubyGems in the standard location, then you probably can’t install gems in the standard gem repository location either. You need to specifiy a non-standard gem repository location via the 
GEM_HOME environment variable.
Use the following to install RubyGems in a user directory (here called 
/home/mystuff) with a repository named 
/home/mygemrepository):
$ export GEM_HOME=/home/mygemrepository $ ruby setup.rb config --prefix=/home/mystuff $ ruby setup.rb setup $ ruby setup.rb install
Notes:
  1. The export command is ksh specific. Use the appropriate command for your OS. For example windows users would probably say:
    set GEM_HOME=/home/mygemrepository
  2. Make sure you add /home/mystuff/bin to your path so that the gem command can be found.
  3. Make sure you add the GEM_HOME setup to your profile, so that RubyGems can find the location of your gem repository.
  4. If you want the gem repository to reside inside the install directory, we recommend setting GEM_HOME prefix_dir/gems. (where prefix_dir is given as the valud of --prefix in the config step)

Modern Versions of RubyGems

If your RubyGems version is 0.8.5 or later, you can upgrade to the latest version with:
gem update --system
Don’t forget to use sudo if your system requires root access to install ruby libraries.

Prior to RubyGems 0.8.5

If you current version of RubyGems is prior to version 0.8.5, then use the following commands:
gem install rubygems-update update_rubygems

Manual Upgrades

Download the latest RubyGems tar or zip file and following the instructions for 
.

Now that you have RubyGems installed, you should be ready to run applications using gems, right?
Well, almost.
You have one more decision to make: How to let Ruby programs know to use the gems repository.
You see, because the of versioned nature of the gems repository, RubyGems doesn’t store the library files directly in standard library search path. It adds the necessary gem packages to the library seach path as needed at run time.
This means that RubyGems must be loaded before any gem libraries are accessable.

The Hard Way

The most direct way to make RubyGems available is to just require it in the source code:
require 'rubygems' require 'some_gem_library' # ...
The big problem with this approach is that you don’t want to make this change to 
every single Ruby program you download! While ok for quick scripts you write yourself, this is not the way to go.

Using the -rubygems Command Line Option

To avoid modifying all the Ruby programs you install, you could tell the 
ruby interpreter to preload ruby gems before running other software. You can easily do this by giving the 
ruby command a 
-rubygems option each time you run a program.
ruby -rubygems my_program_that_uses_gems
This works, and avoids changing installed software, but is a pain to type all the time. Fortunately there is another option.

Using RUBYOPT

By setting the 
RUBYOPT environment variable to the value 
rubygems, you tell Ruby to load RubyGems every time it starts up. This is similar to the 
-rubygems options above, but you only have to specify this once (rather than each time you run a Ruby script).
Unix users will want to put the following line in their 
.profile (or equivalent):
export RUBYOPT=rubygems
Windows users will want to set the 
RUBYOPT environment variable using the appropriate sysetm utility. (On XP you can find it under Settings / Control Panel / System. Click the advanced tab and then the “Environment Variables” button near the bottom. Note that the one-click installer will set up 
RUBYOPT for you automatically (unless you request it not be done).

The Future

The need to preload the RubyGems software is one of the biggest drawbacks to RubyGems’ versioned software approach. The RubyGems team is investigating ways of making this issue much less onerous.
In the meantime, enjoy RubyGems.
本文转自 fsjoy1983 51CTO博客,原文链接:http://blog.51cto.com/fsjoy/63910,如需转载请自行联系原作者
你可能感兴趣的文章
我太水了~
查看>>
Mysql-proxy中的lua脚本编程(一)
查看>>
SY-SUBRC 的含义【转】
查看>>
仓库管理系统用例建模
查看>>
转换数字为人民币大写金额
查看>>
Python爬虫之爬取西刺免费IP并保存到MySQL
查看>>
PostgreSQL的进程结构
查看>>
[HBase_2] HBase数据模型
查看>>
Android之Sqlite数据库
查看>>
高并发编程-CountDownLatch深入解析
查看>>
Sublime 中文标题乱码
查看>>
世界上最幸福的职业-鉴黄师
查看>>
asp.net 10 Cookie & Session
查看>>
[置顶]C# 邮件发送方法【NetMail方式】
查看>>
一个数据库系统的笔试题
查看>>
使用Form个性化修改标准Form的LOV
查看>>
第二阶段冲刺06
查看>>
六、input框中的数字(金额)只能输入正整数
查看>>
UE 正则表达式匹配某一标签内容
查看>>
selenium 模型简单理解
查看>>