我是全新的紅寶石。我寫了一個小腳本,並在頂部我有以下幾點:使用紅寶石
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'
將解決這個問題,但顯然不在我的情況。下一個猜測是我的寶石安裝不正確?
編輯:我要指出的是,我在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
a)Ruby gems內置於Ruby 1中。9,所以你不需要'require'rubygems''行; b)雖然你可能希望rubygems自動下載並安裝腳本所需的寶石,但它不會。在運行腳本之前,您需要先從命令行運行'gem install curb'。 – Phrogz 2012-02-16 23:06:25
感謝迄今的答覆。我試着運行gem install curb,但是在我上面的編輯中出現了錯誤。 – hodgesmr 2012-02-16 23:14:42
也許這是你的新問題,然後:[如何在Windows上安裝限制](http://stackoverflow.com/questions/1511865/install-ruby-curb-gem-in-windows-xp)。 – Phrogz 2012-02-16 23:30:01