ruby1.9.1找不到已安装的gem,而ruby1.8可以
在ubuntu上这里。我安装了ruby1.8和ruby1.9.1。我还运行了这些命令,
ruby1.8 setup.rb
ruby1.9.1 setup.rb
两者都运行良好,我还能够为两者安装 gems。 gem 1.9.1 和 gem1.8 中的 gem 都可以在 gem list
中正确显示。然而问题始于:ruby1.9.1 some_script.rb
。它找不到任何宝石。我尝试取消注释一些内容,发现 parseconfig 是问题所在,但它找不到任何其他内容,这些内容肯定在 gem1.9.1 列表
中。关于造成这种情况的原因/如何恢复有什么想法吗?
编辑/旁注:ruby1.9.1 也无法在 1.8 中找到 gem。不是我想要的! 澄清
只是从 pejuko 的回答中
cd /var/lib/
cd gems
bash: cd: gems: No such file or directory
sudo ln -s /usr/lib/ruby/gems
irb1.9.1
irb(main):001:0> require 'mechanize'
=> true
!:这解决了它!另外,螺丝debian。
On ubuntu here. I installed both ruby1.8 and ruby1.9.1. I also ran these commands
ruby1.8 setup.rb
ruby1.9.1 setup.rb
Both worked fine, I was also able to install gems for both. The gems in gem 1.9.1 and gem1.8 both show up correctly for gem list
. The problems however begin with this: ruby1.9.1 some_script.rb
. It cannot find any of the gems. I tried uncommenting some out figuring that parseconfig was the problem, yet it couldn't find any of the others, which are definetly in gem1.9.1 list
. Any thoughts as to what is causing this/how to recover?
edit/side note: ruby1.9.1 won't be able to find the gems in 1.8 either. Not that I want that! Just clarifying
From pejuko's answer!:
cd /var/lib/
cd gems
bash: cd: gems: No such file or directory
sudo ln -s /usr/lib/ruby/gems
irb1.9.1
irb(main):001:0> require 'mechanize'
=> true
This fixed it! Also, screw debian.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能需要在脚本顶部添加
require 'rubygems'
。这将指示 ruby 加载 gem 系统,然后您将能够从 ruby 1.9.1 运行时找到所有 gem。you probably need to add a
require 'rubygems'
to the top of your scripts. this will instruct ruby to load up the gem system and you'll then be able to find all of your gems from the ruby 1.9.1 runtime.我不知道情况是否如此,但是当我从 rubyforge 安装 rubygems 时,我需要创建一些符号链接,因为 ubuntu 使用与原始目录不同的 gems 目录。我在目录 /usr/lib/ruby/ gems 中符号链接到 /var/lib/gems/
I don't know if this is the case, but when I installed rubygems from rubyforge I needed to create some symlinks because ubuntu uses different directory for gems then the original one. I have in directory /usr/lib/ruby/ gems symlinked to /var/lib/gems/