在windows xp(32位)上在Ruby on Rails上安装Typhoeus

时间:2011-05-19 16:29:24

标签: ruby-on-rails curl libcurl

我一直在尝试在我的“Ruby on Rails”应用程序上做一些简单的“rails服务器”,但是我正在和我的一个使用linux的朋友一起工作,我坐在windows xp(32位)上一切顺利,所有,他实施了名为“curl”和“typhoeus”的宝石,所以为了让我在我的localhost上查看它:3000我必须安装宝石。


所以这就是我写的:


D:\>gem install typhoeus
Building native extensions.  This could take a while...
ERROR:  Error installing typhoeus:
        ERROR: Failed to build gem native extension.

C:/Ruby187/bin/ruby.exe extconf.rb
checking for curl/curl.h in C:/Ruby187/lib/ruby/gems/1.8/gems/typhoeus-0.2.4/cro
ss/curl-7.19.4.win32/include... no
need libcurl
*** 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:/Ruby187/bin/ruby


Gem files will remain installed in C:/Ruby187/lib/ruby/gems/1.8/gems/typhoeus-0.
2.4 for inspection.
Results logged to C:/Ruby187/lib/ruby/gems/1.8/gems/typhoeus-0.2.4/ext/typhoeus/
gem_make.out


是不是它看起来不那么漂亮,但是显然它要求一个叫做“libcurl”的东西,所以我从互联网上下载了用于windows xp 32bit的curl版本,我把exe文件和放大器windows文件夹中的所有dll文件。我试图简单地写“卷曲”以确定它是否有效。这就是我得到的:

D:\>curl
curl: try 'curl --help' or 'curl --manual' for more information

我再次写了宝石安装typhoeus,我得到了与上面相同的错误,我错过了什么? libcurl不是卷曲吗?我迫切需要帮助,因为我的朋友无法帮助我,因为他是一个Linux家伙。所以请帮助我 - 告诉我安装typhoeus必须做些什么! (我也尝试编写gem install typhoeus-0.2.4,但是却抛出了其他一些错误:

ERROR:  Could not find a valid gem 'typhoeus-0.2.4' (>= 0) in any repository

我写的是在rails应用程序中的ruby文件夹中。所以我迷失了,非常需要帮助!

提前致谢,
哈利

4 个答案:

答案 0 :(得分:2)

我在Windows 7上遇到了类似的问题,问题是windows机器的extconf.rb文件中的一些逻辑。以下行是导致need libcurl错误消息的原因:

if Config::CONFIG['target_os'] == 'mingw32'
  header = File.join(ROOT, 'cross', 'curl-7.19.4.win32', 'include')
  unless find_header('curl/curl.h', header)
    abort "need libcurl"
  end

File.join调用导致makefile查找typhoeus中未包含的目录(cross / curl-7.19.4.win32 / include),因此makefile不起作用。

我在网上看了很多解决方案一天中的大部分时间(this link帮助最多),最后通过简单地更改File.join()以使用显式来找到解决方法我的卷曲宝石的文件路径。我编辑了extconf.rb文件两次,一次在这里:

if Config::CONFIG['target_os'] == 'mingw32'
  header = File.join('C:\RailsInstaller\Ruby1.9.2\lib\ruby\gems\1.9.1\gems\curl-7.19.4-devel-mingw32', 'include')
  unless find_header('curl/curl.h', header)
    abort "need libcurl"
  end

一旦到了:

if Config::CONFIG['target_os'] == 'mingw32'
  find_library('curl', 'curl_easy_init',
               File.join('C:\RailsInstaller\Ruby1.9.2\lib\ruby\gems\1.9.1\gems\curl-7.19.4-devel-mingw32', 'bin'))

我相信您可能需要安装DevKit,但我不确定。

希望这有帮助!

答案 1 :(得分:1)

请尝试这个分叉:https://github.com/NoKarma/typhoeus/downloads 我在网上找到了不同的解决方案,但只有这个有效。也许有一天他们最终会修复它在Windows下编译。

答案 2 :(得分:1)

RocketR给出的下载与最新版本的Typhoeus(0.2.4)不兼容。 这篇关于GitHub的评论为我提供了解决方案(https://github.com/dbalatero/typhoeus/issues/11#issuecomment-309957

less involved workaround for typhoeus
0.1.29 on ruby 1.9.1 -- just give it what it wants.

----------- checking for curl/curl.h in C:/path/to/ruby/gems/1.9.1/gems/typhoeus-0.1.29/cross/curl-7.19.4.win32/include... no need libcurl
-----------

download: http://www.gknw.de/mirror/curl/win32/old_releases/curl-7.19.4-devel-mingw32.zip

mkdir C:/path/to/ruby/gems/1.9.1/gems/typhoeus-0.1.29/cross, extract, rename to curl-7.19.4.win32

gem install typhoeus, as you would normally.

答案 3 :(得分:0)

在windows vista / 7上,这不再是Ruby193中的问题。 只需安装typhoeus

宝石安装typhoeus

这在我的vista pc上没有错误。

确保您可以通过将curl.exe放在没有空格的路径以及用户或系统路径中的位置来从任何地方运行curl.exe。

在你的剧本中加入typhoeus,你就完成了。