Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing native Ruby extensions on Windows for 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!

like image 207
Tigraine Avatar asked Sep 03 '10 23:09

Tigraine


People also ask

Do I need Ruby for Jekyll?

To install Jekyll on macOS, you need a proper Ruby development environment. While macOS comes preinstalled with Ruby, we don't recommend using that version to install Jekyll. This external article goes over the various reasons why you shouldn't use the system Ruby.

How do I run Gemfile on Windows?

Typically you can open files from the Command Prompt by just typing the filename, but because Gemfile doesn't have a file extension, no program will automatically open it. You may need to use your File Explorer and browse to the directory, and then open the Gemfile in a text editor such as Notepad.

Can you install Ruby on Windows?

Downloading and Installing RubyAll the versions of Ruby for Windows can be downloaded from rubyinstaller.org. Download the latest version and follow the further instructions for its Installation.


2 Answers

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

like image 174
Luis Lavena Avatar answered Sep 23 '22 02:09

Luis Lavena


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

like image 34
Jörg W Mittag Avatar answered Sep 22 '22 02:09

Jörg W Mittag