Can't install json gem in Windows

2019-02-21 03:10发布

I tried to install the json gem on Windows. I installed DevKit. I get the following error below. Any suggestions? This question

JSON Gem will not install (Windows)

suggests installing DevKit and also try using json_pure. I did both. The problem is that my bundle install is trying to install json and won't proceed until json is installed. This is a bundle install for a Rails project 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条回答
小情绪 Triste *
2楼-- · 2019-02-21 03:44

I had to use the version 1.7.7. I do not why but it seems that it is compatible with your ruby version. Do: gem install json -v '1.7.7'

查看更多
别忘想泡老子
3楼-- · 2019-02-21 03:50

I had this problem too, solved this by doing this:

Using Ruby version - 2.2.2

Gem version - 2.3.0 (if you have the latest gem version install you can downgrade using command - gem update --system 2.3.0)

Please note even if you are 64 bit windows system, download and extract 32 bit devkit (DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe) from here

Once extracted, add the path to devkit & mingw\bin to your path variable Navigate to devkit directory & run below commands

ruby dk.rb init

ruby dk.rb install

Finally, restart the command prompt & try

gem install json

This worked for me. Hope this helps.

查看更多
手持菜刀,她持情操
4楼-- · 2019-02-21 03:54

In my situation, i download wrong version of Ruby (32bit), but i using 64bit windows => error occur. The first thing you need is check if development kit work correctly.

gem install json --platform=ruby

if it cant not work , you should follow bellow tutorial to make it work. https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

And after this, you can install json gem normaly. I think. Good luck.

查看更多
登录 后发表回答