无法在Windows中安装json gem

时间:2013-04-17 22:11:42

标签: ruby json gem devkit

我尝试在Windows上安装json gem。我安装了DevKit。我在下面收到以下错误。有什么建议?这个问题

JSON Gem will not install (Windows)

建议安装DevKit并尝试使用json_pure。我做了两件事。问题是我的bundle install正在尝试安装json,并且在安装json之前不会继续。这是一个用于Rails项目btw的捆绑安装。

d:\source\my_project>gem install json -v '1.6.3'
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing json:
        ERROR: Failed to build gem native extension.

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

make
generating parser-i386-mingw32.def
compiling parser.c
In file included from parser.rl:1:0:
../fbuffer/fbuffer.h:129:13: warning: 'fbuffer_append_long' defined but not used [-Wunused-function]
../fbuffer/fbuffer.h:136:17: warning: 'fbuffer_dup' defined but not used [-Wunused-function]
../fbuffer/fbuffer.h:149:14: warning: 'fbuffer_to_s' defined but not used [-Wunused-function]
../fbuffer/fbuffer.h:90:13: warning: 'fbuffer_append_str' defined but not used [-Wunused-function]
linking shared-object json/ext/parser.so

make install
/usr/bin/install -c -m 0755 parser.so C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.6.3/ext/json/ext/json/ext
/usr/bin/install: cannot create regular file `C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.6.3/ext/json/ext/json/ext': No such file or directory
make: *** [install-so] Error 1


Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.6.3 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.6.3/ext/json/ext/parser/gem_make.out

3 个答案:

答案 0 :(得分:1)

我也有这个问题,通过这样做解决了这个问题:

使用 Ruby版本 - 2.2.2

宝石版 - 2.3.0 (如果您有最新的宝石版安装,可以使用命令降级 - ruby dk.rb init ruby dk.rb install

请注意即使您是64位Windows系统,也要从{{3下载并提取32位devkit( DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe ) }}

提取后,添加devkit&的路径。 mingw \ bin到你的路径变量 导航到devkit目录&在命令下运行

gem install json

最后,重启命令提示符&试试

$string = '<p class="Default"><span style="font-weight: bold;"><span style="mso-bidi-font-size:10.0pt;color:windowtext">+ Tra cứu thông tin; </span></span></p>';

$string = strip_tags(html_entity_decode($string));
var_dump($string);

这对我有用。希望这可以帮助。

答案 1 :(得分:0)

我不得不使用1.7.7版本。 我不是为什么,但似乎它与你的ruby版本兼容。 做:宝石安装json -v' 1.7.7'

答案 2 :(得分:0)

在我的情况下,我下载错误版本的Ruby(32位),但我使用64位windows =>发生错误。 您需要做的第一件事是检查开发工具包是否正常工作。

gem install json --platform=ruby

如果它不能工作,你应该按照下面的教程来使它工作。 https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

在此之后,您可以正常安装json gem。我认为。 祝你好运。

相关问题