gpt4 book ai didi

即使安装了 gem,Ruby 也找不到所需的库

转载 作者:数据小太阳 更新时间:2023-10-29 07:12:26 26 4
gpt4 key购买 nike

我花了几天时间尝试安装 ruby​​ 1.9.2 并让它与 gems 一起工作:-/我最终放弃了我的 Mac OSX 10.6 机器,下面是我的 Ubuntu 机器上的当前状态。任何建议将不胜感激!

# ruby test.rb
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- mongo (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from test.rb:1:in `<main>'
# cat test.rb
require 'mongo'
db = Mongo::Connection.new.db("mydb")
# gem which mongo
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongo-1.1.2/lib/mongo.rb
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu 10.10"

根据此页面:http://docs.rubygems.org/read/chapter/19我符号链接(symbolic link)了我正在使用的 ruby 以匹配正在使用的 gem :

# which ruby
/usr/local/rvm/bin/ruby
# ls -l `which ruby`
lrwxrwxrwx 1 root root 44 2010-11-17 13:25 /usr/local/rvm/bin/ruby -> /usr/local/rvm/rubies/ruby-1.9.2-p0/bin/ruby
# gem env | grep 'RUBY EXECUTABLE'
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.2-p0/bin/ruby
# which gem
/usr/local/rvm/bin/gem
# gem -v
1.3.7
# ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]

最佳答案

尝试将以下行放在开头

require "rubygems"

关于即使安装了 gem,Ruby 也找不到所需的库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4207992/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com