简体   繁体   English

在Mac OS X预先安装的ruby 1.8.7中安装gem

[英]Installing gems in Mac OS X pre-installed ruby 1.8.7

Macs seem to all come with ruby 1.8.7 pre-installed. Mac似乎都预装了ruby 1.8.7。 That's fine for my purposes, but when I install gems with either gem install gem-name or sudo gem install gem-name , I have to explicitly add the gem's lib directory to my $LOAD_PATH at the top of my ruby programs: 出于我的目的,这很好,但是当我使用gem install gem-namesudo gem install gem-name ,必须将宝石的lib目录显式添加到我的ruby程序顶部的$ LOAD_PATH中:

$LOAD_PATH.unshift File.join("/", "Users", "me", ".gems", "more_dirs", "lib")

Why do I have to do this? 为什么我必须这样做? Am I installing gems wrong? 我安装宝石错了吗?

If I then install rvm and the latest ruby 1.9.3, I can install gems no problem with gem install gem-name . 如果然后安装rvm和最新的ruby 1.9.3,则可以安装gems,而gem install gem-name没问题。

With 1.8.7 where rubygems aren't built in. You need to 在1.8.7中没有内置rubygems的地方。您需要

 require 'rubygems'

at the top of your scripts in order to avoid manually setting the paths to your gems (pulling this in from the comments) 在脚本的顶部,以避免手动设置宝石的路径(将其从注释中拉入)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM