错误:无法构建gem原生扩展Windows 7 32位

时间:2017-01-09 09:31:56

标签: ruby-on-rails json ruby ruby-on-rails-4 devkit

我正在尝试在Windows 7 32系统上安装json ruby​​ gem。

本地环境详情

D:\Environment\DevKit32Ruby200>gem -v
2.0.14

D:\Environment\DevKit32Ruby200>ruby -v
ruby 2.0.0p451 (2014-02-24) [i386-mingw32]

D:\Environment\DevKit32Ruby200>rails -v
Rails 4.0.4

我已经尝试过以下内容

  1. 使用

    将系统ruby gems版本降级到2.3.0
    gem update --system 2.3.0
    
  2. 我已经正确设置了devkit并手动在config.yml文件中添加了正确的ruby目录路径。

    D:\Environment\DevKit32Ruby200>ruby dk.rb init
    
     Initialization complete! Please review and modify the auto-generated
     'config.yml' file to ensure it contains the root directories to all
     of the installed Rubies you want enhanced by the DevKit.
    
    D:\Environment\DevKit32Ruby200>ruby dk.rb install --force
        [WARN] Updating (with backup) existing gem override for                            'D:/Environment/ruby200new'
       [WARN] Updating (with backup) DevKit helper library for 'D:/Environment/ruby200new'
    
  3. 我也试过把platform = ruby​​

    gem install json --platform=ruby --verbose
    
  4. 安装json时遇到的错误如下:

    D:\Environment\DevKit32Ruby200>gem install json
    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.
    
        D:/Environment/ruby200new/bin/ruby.exe extconf.rb
    creating Makefile
    
    make "DESTDIR="
    generating generator-i386-mingw32.def
    compiling generator.c
    linking shared-object json/ext/generator.so
    
    make "DESTDIR=" install
    /usr/bin/install -c -m 0755 generator.so ./.gem.20170109-8336-qvgvzc/json/ext
    make: execvp: /usr/bin/install: Permission denied
    make: *** [install-so] Error 127
    
    
    Gem files will remain installed in D:/Environment/ruby200new/lib/ruby/gems/2.0.0/gems/json-2.0.2 for inspection.
    Results logged to D:/Environment/ruby200new/lib/ruby/gems/2.0.0/gems/json-2.0.2/ext/json/ext/generator/gem_make.out
    

    此问题已标记了10个问题但未解决。 请帮助我确定丢失的内容以及错误发生的原因。

2 个答案:

答案 0 :(得分:2)

i386-mingw32是一大堆痛苦,永远不会得到完全支持,当我在Windows上度过时,我曾经使用安装了ubuntu的VirtualBox VM与Windows主机共享一个文件夹。我会在windows中使用netbeans编辑文件并在putty中运行代码,VM基本上是无头的。

我实际上通过这种方式做了很多真正的工作。如果你想做一个" Hello World" rails app - OK - 祝你好运。如https://c9.io/等在线开发环境怎么样?

但是如果你想工作,不仅仅是玩游戏,至少可以使用Ubuntu VM,或者最好在Ubuntu / MacOS中工作。

答案 1 :(得分:0)

试试这个:

为什么不从rubygems.org下载json .gem文件并使用命令直接安装

gem install json-x.x.x.gem