rvm不导入gem路径

时间:2014-07-11 13:32:57

标签: ruby gem rvm osx-yosemite

我在Mac OS X Yosemite 10.10 Beta 3上运行,我重新安装了rvm(删除了我能想到的所有内容并重新安装了整个内容。

尝试运行我在Mavericks工作的脚本。

Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ gem install restclient
Successfully installed restclient-0.10.0
Parsing documentation for restclient-0.10.0
Done installing documentation for restclient after 0 seconds
1 gem installed
Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ which irb
/Users/maximveksler/.rvm/rubies/ruby-2.1.2/bin/irb
Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ irb
2.1.2 :001 > require 'restclient'
LoadError: cannot load such file -- restclient
    from /Users/maximveksler/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/maximveksler/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from (irb):1
    from /Users/maximveksler/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `<main>’

路径看起来很正常

Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ env | grep GEM
GEM_HOME=/Users/maximveksler/.rvm/gems/ruby-2.1.2
GEM_PATH=/Users/maximveksler/.rvm/gems/ruby-2.1.2:/Users/maximveksler/.rvm/gems/ruby-2.1.2@global

还安装了宝石

Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ file /Users/maximveksler/.rvm/gems/ruby-2.1.2/gems/restclient-0.10.0/lib/rest_client.rb
/Users/maximveksler/.rvm/gems/ruby-2.1.2/gems/restclient-0.10.0/lib/rest_client.rb: ASCII C++ program text

那么我错过了什么?

1 个答案:

答案 0 :(得分:1)

查看您的链接here,语法中存在错误。它应该是require 'rest_client'而不是require 'restclient'。你的版本仍然有效的原因就像你说的那样,因为有一个名为restclient.rb的文件,它被用作gem提供的附加restclient二进制文件的源代码(这违反了常规命名约定,你应该提交一个github上)。

现在因为您需要此文件(restclient.rb)用于设置已有RestClient可用的环境,所以它实际上与要求rest_client相同。但是它可能会产生意想不到的后果,所以你应该坚持文档中概述的惯例。

这一切都来自阅读文档here并浏览文件here。那有意义吗?我担心这两个文件非常相似并不清楚。