Bluecloth v2.0.10 with windows 7 not working

陌路散爱 提交于 2020-01-23 05:49:26

问题


WIth Ruby 187, I had downloaded devkit from http://rubyinstaller.org/downloads and followed the instruction per https://github.com/oneclick/rubyinstaller/wiki/Development-Kit. I had also ensured that devkit is installed properly by following smoke test.

I had then tried installing bluecloth (v2.0.10). It had failed with following error:

C:\test\typo>gem install bluecloth --platform=ruby

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing bluecloth:
       ERROR: Failed to build gem native extension.

c:/Ruby187/bin/ruby.exe extconf.rb
checking for srand()... yes
checking for random()... no
checking for rand()... yes
checking for bzero() in string.h,strings.h... no
checking for strcasecmp()... yes
checking for strncasecmp()... yes
checking for mkdio.h... yes
checking for ruby/encoding.h... no
creating extconf.h
creating Makefile

make
gcc -I. -I. -Ic:/Ruby187/lib/ruby/1.8/i386-mingw32 -I. -
DRUBY_EXTCONF_H=\"extcon
f.h\"    -DVERSION=\"2.0.4\" -g -O2 -DFD_SETSIZE=256   -I. -Wall  -c
bluecloth.c

In file included from c:\rubydevkit\mingw\bin\../lib/gcc/
mingw32/4.5.1/../../../../include/windows.h:48:0,
                from c:\rubydevkit\mingw\bin\../lib/gcc/
mingw32/4.5.1/../../../../include/winsock2.h:22,
                from c:/Ruby187/lib/ruby/1.8/i386-mingw32/win32/
win32.h:27,
                from c:/Ruby187/lib/ruby/1.8/i386-mingw32/defines.h:
186,
                from c:/Ruby187/lib/ruby/1.8/i386-mingw32/ruby.h:37,
                from bluecloth.h:14,
                from bluecloth.c:25:
c:\rubydevkit\mingw\bin\../lib/gcc/mingw32/4.5.1/../../../../include/
windef.h:229:23: error: duplicate 'unsigned'
c:\rubydevkit\mingw\bin\../lib/gcc/mingw32/4.5.1/../../../../include/
windef.h:238:23: error: duplicate 'unsigned'
c:\rubydevkit\mingw\bin\../lib/gcc/mingw32/4.5.1/../../../../include/
windef.h:238:23: error: two or more data types in declaration
specifiers
c:\rubydevkit\mingw\bin\../lib/gcc/mingw32/4.5.1/../../../../include/
windef.h:241:24: error: duplicate 'unsigned'
bluecloth.c: In function 'bluecloth_initialize':
bluecloth.c:190:9: warning: unused variable 'utf8text'
make: *** [bluecloth.o] Error 1

Gem files will remain installed in c:/Ruby187/lib/ruby/gems/1.8/gems/
bluecloth-2.0.10 for inspection.
Results logged to c:/Ruby187/lib/ruby/gems/1.8/gems/bluecloth-2.0.10/
ext/gem_make.out

C:\test\typo>

回答1:


If you need 2.2.0 (the latest version), here's how I got it to work:

  1. Install DevKit

  2. Run the command below to install bluecloth:

    gem install bluecloth

    this will fail miserably when building "native extensions", but will successfully install the gem's source code.

  3. Patch bluecloth.h file (for me, this is found in: D:\ruby\Ruby-1.9.3-p125\lib\ruby\gems\1.9.1\gems\bluecloth-2.2.0\ext), with the patch from here: https://gist.github.com/1539611

  4. Go to bluecloth's gem installation folder. For me, this looks like below:

    D:\ruby\Ruby-1.9.3-p125\lib\ruby\gems\1.9.1\gems\bluecloth-2.2.0

  5. Run the following command:

    rake gem

    It may prompt you to install some other gems, follow accordingly. When it's done, you should see a bluecloth-2.2.0.gem created. For me, it is found here:

    D:\ruby\Ruby-1.9.3-p125\lib\ruby\gems\1.9.1\gems\bluecloth-2.2.0\pkg\bluecloth-2.2.0.gem

  6. Go to bluecloth-2.2.0.gem location, and run the following command:

    gem install bluecloth-2.2.0.gem --platform=ruby




回答2:


It seems there is a bug/issue with version 2.0.10 of BlueCloth. You can try using an older version like 2.0.7:

gem install bluecloth -v 2.0.7

Which seems to work.

Also probably this worth checking latest version (2.2.0?) and if not work, report it back to gem author:

http://deveiate.org/projects/BlueCloth/query




回答3:


This is the patched bluecloth.h code, for people in a hurry...

#ifndef BLUECLOTH_H
#define BLUECLOTH_H
 
#include "ruby.h"

#if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H
#	define M17N_SUPPORTED
#	include "ruby/encoding.h"
#endif

#include "config.h"
#include "assert.h"
 
#include "mkdio.h"
 
void mkd_initialize  		_(( void ));
void mkd_with_html5_tags	_(( void ));
 
/* Replace the macro from encoding.h that refers to static 'rb_encoding_list' */
#ifdef ENC_FROM_ENCINDEX
#undef ENC_FROM_ENCINDEX
#define ENC_FROM_ENCINDEX(idx) (rb_enc_from_index(idx))
#endif

#endif



回答4:


There's a fork on github that already includes the patch:

https://github.com/drakontia/bluecloth



来源:https://stackoverflow.com/questions/4932221/bluecloth-v2-0-10-with-windows-7-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!