我在Windows上,运行gem install json —platform=ruby
时出现以下错误: gem install json —platform=ruby
:
The system cannot find the path specified. Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... The system cannot find the path specified. ERROR: Error installing json: ERROR: Failed to build gem native extension. C:/Ruby193/bin/ruby.exe extconf.rb creating Makefile Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection. Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
所以首先,我不是一个Windows的人,所以这是一个对我来说是一个勇敢的新世界。 inheritance了一个笔记本电脑的工作,有疯狂的图书馆collections遍布它,我设法删除所有以前的安装ruby和Devkit,然后安装以下内容:
C:/Ruby193
C:/Ruby200
Ruby C:/Ruby200
DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe
(对于ruby 1x)提取到C:/Ruby193-devkit
DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe
(32位为ruby2x)提取到C:/Ruby200-devkit-x32
。 然后,我将Pik 0.2.8安装为gem,并按照安装说明将pik_install
运行到新目录C:/bin
中。
我的path如下所示:
PATH=C:\bin;C:\Ruby193\bin;C:\windows;C:\windows\system32;C:\windows\system32\Wbem;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Java\jdk1.6.0_33\bin;C:\Program Files (x86)\Common Files\Apple\Mobile Device Support\;C:\Program Files (x86)\Common Files\Apple\Apple Application Support;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:/inpath;C:\Program Files (x86)\WinMerge;C:\ChromeDriver;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64
重要的是C:/bin
和C:/Ruby193/bin
在path中。 这意味着当我启动一个shell的时候默认加载了ruby 1.9.3,我可以用pik use 2.0.0p353
成功切换到2.0.0。 换句话说,pik工作正常。
Devkit 旨在允许从Windows上的gem编译本机C / C ++二进制文件,以避免使用预编译的Windows二进制文件。
因为我已经安装了两个ruby版本,并且每个都需要一个不同的开发工具包(一个用于2x和一个用于1x),所以我必须为devkit安装两次:
cd C:/Ruby193-devkit ruby dk.rb init # Edit config.yml to remove all but Ruby193 ruby dk.rb install cd C:/Ruby200-devkit ruby dk.rb init # Edit config.yml to remove all but C:/Ruby200 ruby dk.rb install
在这一点上,我应该已经能够成功地运行gem install json —platform=ruby
,但得到了上面的错误。 经过一点挖掘, 我发现这一点 ,build议检查COMSPEC设置正确,并从HKEY_CURRENT_USER\Software\Microsoft\Command Processor
删除任何AutoRun密钥 – 我有一个来自ANSIcon并正确删除它。
不幸的是我仍然无法安装JSONgem。
这让我感到震惊,也许海湾合作委员会的错误版本正在被使用或未被发现。 Devkit的两个版本有不同版本的gcc:
> C:\Ruby193-devkit\mingw\bin\gcc —version gcc (tdm-1) 4.5.2 > C:\Ruby200-devkit-x32\mingw\bin\gcc —version gcc (rubenv-4.7.2-release) 4.7.2
然后我想知道,如果pik没有加载devtools的版本(因此gcc)为我select的特定版本的ruby,并始终使用1.9.3。 感谢这篇文章 ,似乎并非如此:
> pik use 193 > where ruby C:\Ruby193\bin\ruby.exe > cat C:\Ruby193\lib\ruby\site_ruby\devkit.rb # enable RubyInstaller DevKit usage as a vendorable helper library unless ENV['PATH'].include?('C:\\Ruby193-devkit\\mingw\\bin') then puts 'Temporarily enhancing PATH to include DevKit...' ENV['PATH'] = 'C:\\Ruby193-devkit\\bin;C:\\Ruby193-devkit\\mingw\\bin;' + ENV['PATH'] end ENV['RI_DEVKIT'] = 'C:\\Ruby193-devkit' ENV['CC'] = 'gcc' ENV['CXX'] = 'g++' ENV['CPP'] = 'cpp' > pik use 200 > where ruby C:\Ruby200\bin\ruby.exe > cat C:\Ruby200\lib\ruby\site_ruby\devkit.rb # enable RubyInstaller DevKit usage as a vendorable helper library unless ENV['PATH'].include?('C:\\Ruby200-devkit-x32\\mingw\\bin') then phrase = 'Temporarily enhancing PATH to include DevKit...' if defined?(Gem) Gem.ui.say(phrase) if Gem.configuration.verbose else puts phrase end puts "Prepending ENV['PATH'] to include DevKit..." if $DEBUG ENV['PATH'] = 'C:\\Ruby200-devkit-x32\\bin;C:\\Ruby200-devkit-x32\\mingw\\bin;' + ENV['PATH'] end ENV['RI_DEVKIT'] = 'C:\\Ruby200-devkit-x32' ENV['CC'] = 'gcc' ENV['CXX'] = 'g++' ENV['CPP'] = 'cpp'
(我实际上并没有在窗户上提供猫,但它使得一个更清晰的解释)
正如你所看到的,devkit正确的版本正在被devkit.rb添加到path中,显然是因为我的错误包含了“Temporarily enhance PATH to include DevKit …”。
它是:
The system cannot find the path specified. Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... The system cannot find the path specified. ERROR: Error installing json: ERROR: Failed to build gem native extension. C:/Ruby193/bin/ruby.exe extconf.rb creating Makefile Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection. Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
不幸的是,结果日志并没有提供很多帮助。 这就是gem_make.out的样子:
C:/Ruby193/bin/ruby.exe extconf.rb creating Makefile
我以为extconf.rb
可能会提供一些帮助,但是我不能使它的头或尾巴:
require 'mkmf' unless $CFLAGS.gsub!(/ -O[\dsz]?/, ' -O3') $CFLAGS << ' -O3' end if CONFIG['CC'] =~ /gcc/ $CFLAGS << ' -Wall' unless $DEBUG && !$CFLAGS.gsub!(/ -O[\dsz]?/, ' -O0 -ggdb') $CFLAGS << ' -O0 -ggdb' end end $defs << "-DJSON_GENERATOR" create_makefile 'json/ext/generator'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator
的Makefile 如下所示 。 我觉得这个Makefile甚至被创build出来似乎很奇怪。
如果有更多的Windows / Ruby经验的人可以摆脱这一点,这将是惊人的!
PS。 我在Windows 7 Professional SP1上
所以我想检查一下devkit是否用正确的devkit目录来加强path。 感谢来自另一个SO问题的build议,我移动了Ruby目录中的devkit安装:
tdm devkit现在位于C:\Ruby193\devkit
devkit中,而mingw64位于C:\Ruby200\devkit
。 运行ruby dk.rb install -f
为每个ruby dk.rb install -f
,我打开了两个devkit.rb文件来检查path是否已被正确更新。 他们有,我更新的提示,所以它应该打印“暂时增强PATH做包括1.9的DevKit”或“暂时增强PATH做包括DevKit为2”。 通过确认正在加载正确的devkit:
C:\>pik 193 C:\>ruby -rdevkit -ve "puts ENV['PATH']" ruby 1.9.3p484 (2013-11-22) [i386-mingw32] Temporarily enhancing PATH to include DevKit for 1.9... C:\Ruby193\devkit\bin;C:\Ruby193\devkit\mingw\bin;C:\bin;C:\Ruby193\bin;C:\windows;C:\windows\system32;C:\windows\system32\Wbem;c:\Program Files (x86) \Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Pro gram Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Java\jdk1.6.0_33\bin;C:\Program Files (x86)\Common Files\Apple\Mobile Device Su pport\;C:\Program Files (x86)\Common Files\Apple\Apple Application Support;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin ;C:/inpath;C:\Program Files (x86)\WinMerge;C:\ChromeDriver;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\sy swow64 C:\>pik 200 C:\>ruby -rdevkit -ve "puts ENV['PATH']" ruby 2.0.0p353 (2013-11-22) [i386-mingw32] Temporarily enhancing PATH to include DevKit for 2... C:\Ruby200\devkit\bin;C:\Ruby200\devkit\mingw\bin;C:\bin;C:\Ruby200\bin;C:\windows;C:\windows\system32;C:\windows\system32\Wbem;c:\Program Files (x86) \Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Pro gram Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Java\jdk1.6.0_33\bin;C:\Program Files (x86)\Common Files\Apple\Mobile Device Su pport\;C:\Program Files (x86)\Common Files\Apple\Apple Application Support;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin ;C:/inpath;C:\Program Files (x86)\WinMerge;C:\ChromeDriver;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\sy swow64
所有看起来像是正常工作。 但:
C:\>gem install json --platform=ruby Temporarily enhancing PATH to include DevKit for 2... Building native extensions. This could take a while... The system cannot find the path specified. ERROR: Error installing json: ERROR: Failed to build gem native extension. C:/Ruby200/bin/ruby.exe extconf.rb creating Makefile Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.8.1 for inspection. Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out C:\>pik 193 C:\>gem install json --platform=ruby Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... The system cannot find the path specified. ERROR: Error installing json: ERROR: Failed to build gem native extension. C:/Ruby193/bin/ruby.exe extconf.rb creating Makefile Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection. Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
这清楚地告诉我们两件事情:
我要看看是否可以使用生成的Makefiles手动构build。
所以这不是世界上最好的答案,但是我似乎偶然发现了一个解决方案。 如果我设置详细标志,一切工作正常:
gem install json --platform=ruby --verbose
这里有一个日志: http : //gist.github.com/dannysmith/8055495
这没有任何意义 – 如果有人能解释为什么这似乎纠正了错误,这将是非常好的。 也许这是一个devkit中的错误?
我有版本1.8.1安装gem json,但我无法解决这个问题的JSON 1.6.1使用
gem install json --platform=ruby --verbose
所以,我从这里尝试https://github.com/oneclick/rubyinstaller/issues/184
gem update --system 2.0.3
在那之后
gem install json -v 1.6.1 --platform=ruby --verbose
它解决了Win7(64位)机器的Json 1.6.1特有的问题
尝试以管理员模式运行命令提示符。 过了7-10个小时后,我明白了这一点。
在Windows上安装32位版本…
ver windows 6.1.76011
64位给出了有关makefile和头文件的错误信息。 尝试了所有其他的建议,包括有关COMSPEC和注册表的rubyinstaller,将gcc添加到路径等。 一些宝石会安装,但git_fame和json将不需要编译。
编辑:它看起来像git_fame使用mimer_plus。 mimer_plus假定gnu工具(unix工具)。 看起来你需要先安装mingw。 这在rubyinstaller页面上并没有明确指出。
我有同样的问题。 我用powershell来检查我的路径
ps> $ s = $ env:路径
ps> $ s.split(“{;}”)
果然,我的红宝石不在路上。 我的路径中有ruby \ bin,但是mingw \ bin位于不同的文件夹下。 我进入我的环境路径,并添加它,我的安装工作。
确保您安装的ruby版本(32或64位)与DevKit版本相匹配。 他们都必须是32或64,这是我所遇到的问题。 在这里可能不是确切的问题,但我想我会把它扔在那里。 这里有一个值得检查的帖子:
在Windows上的Rails – 安装问题