在 Windows 上为 Jekyll 安装本机 Ruby 扩展

发布于 2024-09-17 19:51:43 字数 1969 浏览 14 评论 0原文

我快要疯了,所以我只想问:

你到底是如何在 Windows 上安装 Ruby Gem Jekyll 的?

Jekyll 依赖于 fast-stemmer-1.0.0 并且必须将其构建为本机扩展

我在 RubyDevKit 在 Windows 上安装“正常”环境并且它可以工作,但是 fast-stemmer 仍然一心一意地使用 nmake 来构建二进制文件,并返回以下错误:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>gem install jekyll
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing jekyll:
        ERROR: Failed to build gem native extension.

C:/Ruby/bin/ruby.exe extconf.rb
creating Makefile

nmake

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl -nologo -I. -IC:/Ruby/lib/ruby/1.8/i386-mswin32 -IC:/Ruby/lib/ruby/1.
8/i386-mswin32 -I. -MD -Zi -O2b2xg- -G6  -c -Tcporter.c
cl : Command line warning D9035 : option 'Og-' has been deprecated and will be r
emoved in a future release
cl : Command line warning D9002 : ignoring unknown option '-G6'
porter.c
porter.c(31) : fatal error C1083: Cannot open include file: 'stdlib.h': No such
file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\cl.EXE"' : return code '0x2'
Stop.


Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/fast-stemmer-1
.0.0 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/fast-stemmer-1.0.0/ext/gem_make
.out

我正在使用正如其他文章中所建议的,Visual Studio 2010 附带的 nmake 位于 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin 中。但还是不行。

我尝试从 DevKit 附带的 MSYS shell 运行 gem install,所以当时我确实有 Unix make,但我不知道如何指示 Ruby 使用 make 而不是 nmake(并读取 mkmf.txt 文件)。 rb 也没有启发我)。它一意孤行地使用 nmake ,但它失败了并出现上述错误消息

任何对此的帮助将不胜感激!

更新 我终于意识到我没有通过 RubyInstaller.org 安装 Ruby。我使用安装程序重新安装,现在使用 DevKit 构建 jekyll 工作正常。

感谢大家指出这一点!

I'm about to go crazy here so I'll just ask:

How the hell do you install the Ruby Gem Jekyll on Windows.

Jekyll depends on fast-stemmer-1.0.0 and that has to be built as a native extension

I found this handy guide on RubyDevKit to install a 'sane' environment on Windows and it works, but fast-stemmer is still hell bent on using nmake to build the binaries and that returns the following error:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>gem install jekyll
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing jekyll:
        ERROR: Failed to build gem native extension.

C:/Ruby/bin/ruby.exe extconf.rb
creating Makefile

nmake

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl -nologo -I. -IC:/Ruby/lib/ruby/1.8/i386-mswin32 -IC:/Ruby/lib/ruby/1.
8/i386-mswin32 -I. -MD -Zi -O2b2xg- -G6  -c -Tcporter.c
cl : Command line warning D9035 : option 'Og-' has been deprecated and will be r
emoved in a future release
cl : Command line warning D9002 : ignoring unknown option '-G6'
porter.c
porter.c(31) : fatal error C1083: Cannot open include file: 'stdlib.h': No such
file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\cl.EXE"' : return code '0x2'
Stop.


Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/fast-stemmer-1
.0.0 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/fast-stemmer-1.0.0/ext/gem_make
.out

I'm using the nmake that came with Visual Studio 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin as suggested in some other Article. But it still doesn't work.

I've tried running the gem install from the MSYS shell that comes with the DevKit so I do have the Unix make at that point, but I don't know how to instruct Ruby to use make instead of nmake (and reading the mkmf.rb didn't enlighten me either). It's hell bent on using nmake and that fails pretty with the above error message

Any help on this would be greatly appreciated!

Update
I finally realized that I had not installed Ruby through RubyInstaller.org. I reinstalled using the Installer and now building jekyll with the DevKit works fine.

Thanks to everyone for pointing that out!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苦笑流年记忆 2024-09-24 19:51:43

您所遵循的说明存在混乱。 RubyInstaller DevKit 上的说明旨在支持使用 RubyInstaller 编译版本的 Ruby 安装扩展。

很明显,从您当前的目录 (Visual Studio) 和 gem 安装的输出来看,您正在使用基于 mswin32 的 Ruby,这不适用于我们记录的 RubyInstaller 或 DevKit。

请从 RubyInstaller 网站安装 Ruby 和 DevKit,并按照其中的说明进行操作并避免与 Visual Studio 混合

There is a confusion with the instructions you're following. The instructions at RubyInstaller DevKit were created to support installation of extensions using RubyInstaller compiled versions of Ruby.

It is clear, from your current directory (visual studio) and the output of the gem installation you're using mswin32 based Ruby, which will not work with RubyInstaller or the DevKit we documented.

Please install Ruby and the DevKit from RubyInstaller website and follow the instructions there and avoid mixing with Visual Studio

帅的被狗咬 2024-09-24 19:51:43

mswin32 从哪里来?您是否将 DevKit 与 MRI 的 mswin32 端口一起使用? DevKit 仅适用于 MRI 和 YARV 的当前 MinGW 端口,它不适用于 mswin32 端口(顺便说一句,该端口已经过时相当长一段时间了)。

如果您使用 mswin32 端口,您或多或少就得靠自己了。特别是,您必须使用 Microsoft Visual C++ 6.0,因为这是编译 mswin32 端口的版本,并且不保证更高版本的 Visual C++ 二进制兼容。 Visual C++ 10.0(您似乎正在使用的)不起作用。尝试通过显式调用 gem install --platform=mswin32 fast-stemmer 甚至 gem install --platform=x86-mswin32-60 fast-stemmer 来强制使用平台。这样,如果维护者提供了预编译版本,您就不需要自己编译。

如果您使用 mswin32 端口而是使用 MinGW 端口,请尝试显式调用 gem install --platform=ruby fast-stemmer。如果这没有帮助,请尝试 gem install --platform=x86-mingw32 fast-stemmer

Where does that mswin32 come from? Are you using the DevKit with the mswin32 port of MRI? The DevKit is only for the current MinGW port of MRI and YARV, it does not work with the mswin32 port (which, BTW, has been obsolete for quite some time now).

If you use the mswin32 port, you are more or less on your own. In particular, you must use Microsoft Visual C++ 6.0, because that's what the mswin32 port is compiled with, and later versions of Visual C++ are not guaranteed to be binary compatible. Visual C++ 10.0 (which is what you seem to be using) does not work. Try forcing the platform by explicitly calling gem install --platform=mswin32 fast-stemmer or even gem install --platform=x86-mswin32-60 fast-stemmer. That way, if the maintainer has provided a pre-compiled version, you don't need to compile it yourself.

If you do not use the mswin32 port but rather the MinGW port, try explicitly calling gem install --platform=ruby fast-stemmer. And if that doesn't help, try gem install --platform=x86-mingw32 fast-stemmer

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文