新手问题 [已解决] gem install 安装成功的 gem, 用 gem list 还是找不到

springwq · 2013年07月14日 · 最后由 Ryan 回复于 2013年07月14日 · 17689 次阅读

在 Mac 下安装缺失的 Gem, 但是安装成功后,ruby 程序还是无法加载,gem list 里面也没有。

安装过程:

16:25 WuQi@MBP ~/code/ruby/bdd/5 (master) $ sudo gem install shoulda
Password:
Fetching: shoulda-context-1.1.4.gem (100%)
Successfully installed shoulda-context-1.1.4
Fetching: i18n-0.6.4.gem (100%)
Successfully installed i18n-0.6.4
Fetching: multi_json-1.7.7.gem (100%)
Successfully installed multi_json-1.7.7
Fetching: tzinfo-0.3.37.gem (100%)
Successfully installed tzinfo-0.3.37
Fetching: atomic-1.1.10.gem (100%)
Building native extensions.  This could take a while...
Successfully installed atomic-1.1.10
Fetching: thread_safe-0.1.0.gem (100%)
Successfully installed thread_safe-0.1.0
Fetching: activesupport-4.0.0.gem (100%)
Successfully installed activesupport-4.0.0
Fetching: shoulda-matchers-2.2.0.gem (100%)
Successfully installed shoulda-matchers-2.2.0
Fetching: shoulda-3.5.0.gem (100%)
Successfully installed shoulda-3.5.0
Parsing documentation for shoulda-context-1.1.4
Installing ri documentation for shoulda-context-1.1.4
Parsing documentation for i18n-0.6.4
Installing ri documentation for i18n-0.6.4
Parsing documentation for multi_json-1.7.7
Installing ri documentation for multi_json-1.7.7
Parsing documentation for tzinfo-0.3.37
Installing ri documentation for tzinfo-0.3.37
Parsing documentation for atomic-1.1.10
unable to convert "\xCF" from ASCII-8BIT to UTF-8 for lib/atomic_reference.bundle, skipping
Installing ri documentation for atomic-1.1.10
Parsing documentation for thread_safe-0.1.0
Installing ri documentation for thread_safe-0.1.0
Parsing documentation for activesupport-4.0.0
unable to convert "\x80" from ASCII-8BIT to UTF-8 for lib/active_support/values/unicode_tables.dat, skipping
Installing ri documentation for activesupport-4.0.0
Parsing documentation for shoulda-matchers-2.2.0
Installing ri documentation for shoulda-matchers-2.2.0
Parsing documentation for shoulda-3.5.0
Installing ri documentation for shoulda-3.5.0
9 gems installed

但是 gem list 还是找不到:


16:45 WuQi@MBP ~/code/ruby/bdd/4 (master) $ gem list shoulda

*** LOCAL GEMS ***


16:49 WuQi@MBP ~/code/ruby/bdd/4 (master) $

可能你 sudo 环境用的 gem 和用户环境的 gem 不是一个,比如 sudo 用的是系统 gem,用户环境的是 rvm 安装的 gem。

RVM 的安装的话,Ubuntu 下是有这个问题的,我在 Ubuntu 下,用这条命令,不知道有没有用。 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 好的话,加到 profile 里。

@Rei @hunter 删除并重新装了 rvm, 现在问题解决了,之前 rvm 有些东西是用 sudo  安装的。可以正常安装 gem 了

一看到命令第一句是 sudo 就知道问题所在了。感觉 gem 安装不一定要 sudo 啊。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册