我是红宝石的新手。我写了一个小脚本,在顶部我有以下内容:
require 'rubygems'
require 'net/http'
require 'json'
require 'curb'
但是当我尝试运行脚本时,我得到以下内容:
C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot loa
d such file -- curb (LoadError)
from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require
'
from rImDrop.rb:4:in `<main>'
到目前为止我发现的所有内容都表明require 'rubygems'
会解决这个问题,但显然不是我的情况。下一个猜测是我的Gems安装不正确吗?
编辑:我应该指出我在Windows 7上...
当我运行gem install curb
时,我得到:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing curb:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
checking for curl-config... no
checking for main() in -lcurl... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby193/bin/ruby
--with-curl-dir
--without-curl-dir
--with-curl-include
--without-curl-include=${curl-dir}/include
--with-curl-lib
--without-curl-lib=${curl-dir}/lib
--with-curllib
--without-curllib
extconf.rb:23:in `<main>': Can't find libcurl or curl/curl.h (RuntimeError)
Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
options to extconf.
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/curb-0.8.
0 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/curb-0.8.0/ext/gem_make.ou
t
答案 0 :(得分:9)
我在ubuntu和
上遇到了同样的错误gem install curb
也没用。这虽然有效:
sudo apt-get install libcurl3-dev
答案 1 :(得分:1)
您是否通过“gem install curb”在shell中安装了gem?前两个,Net :: HTTP和JSON,是Ruby 1.9标准库的一部分,因此它们实际上根本不使用RubyGems。
答案 2 :(得分:0)
你能试试吗
gem list
您将获得已安装宝石的列表。如果缺少路缘,则不会安装。
然后你可以使用(如果你在线):
gem install curb
安装它。宝石将从互联网上加载和安装(如果存在依赖性,则会询问您是否应安装它们。)
答案 3 :(得分:0)
答案在于这两行:
checking for curl-config... no
checking for main() in -lcurl... no
这意味着系统搜索了curl库但没有找到它。
你需要curl库及其dev文件(源代码)来编译gem。
答案 4 :(得分:0)
Ruby中的一些库不是纯粹的ruby实现,而是依赖于系统可执行文件和二进制文件。遏制就是其中之一。
在您的系统上安装curl
e.g。在redhat
yum install curl-devel