我在Windows上运行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用户,所以这对我来说是一个勇敢的新世界。从工作中继承了一台笔记本电脑,这些笔记本电脑遍布各处,我已经成功删除了所有以前安装的ruby和Devkit,然后安装了以下内容:
C:/Ruby193
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
(红宝石2x为32位)提取到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
在路径中。这意味着当我启动shell时默认加载ruby 1.9.3并且我可以使用pik use 2.0.0p353
成功切换到2.0.0。换句话说,pik工作正常。
Devkit is intended允许从Windows上的gems编译本机C / C ++二进制文件,以便使用预编译的Windows二进制文件进行编译。
因为我安装了两个版本的ruby,并且每个版本都需要一个不同的devkit(一个用于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
,但是上面的错误。稍作挖掘I discovered this,建议检查COMSPEC是否已设置为核心并从HKEY_CURRENT_USER\Software\Microsoft\Command Processor
删除任何AutoRun密钥 - 我有一个来自ANSIcon并正确删除它。
不幸的是,我仍然无法安装json gem。
然后让我感到震惊的是,或许正在使用GCC的错误版本,或者没有被发现。 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是否没有为我选择的特定版本的ruby加载devtools(以及因此gcc)的版本,并且始终使用1.9.3。感谢this article,似乎并非如此:
> 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'
(我实际上并没有在Windows上使用cat,但它可以提供更清晰的解释)
正如您所看到的,看起来devkit.rb正在将正确版本的devkit添加到路径中,显然正在加载,因为我的错误包含“暂时增强PATH以包含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
looks like this中的Makefile。对我来说这个Makefile甚至被创建似乎很奇怪。
如果任何拥有更多Windows / Ruby经验的人可以对此有所了解,那就太棒了!
PS。我使用的是Windows 7 Professional SP1
所以我想检查devkit是否正确地使用正确的devkit目录增强了路径。感谢另一个SO问题的建议,我将devkit安装移到了Ruby目录中:
tdm devkit现在位于C:\Ruby193\devkit
,而mingw64位于C:\Ruby200\devkit
。在为每个devkit运行ruby dk.rb install -f
之后,我打开了两个devkit.rb文件来检查路径是否已正确更新。他们有,并且我更新了看跌期权,因此它应该打印“暂时增强PATH确实包括DevKit for 1.9”或“暂时增强PATH包括DevKit for 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
这清楚地告诉我们两件事:
我将看看是否可以使用生成的Makefile手动构建。
答案 0 :(得分:11)
所以这不是世界上最好的答案,但我似乎偶然发现了一个解决方案。如果我设置详细标志,一切正常:
gem install json --platform=ruby --verbose
这里有一个日志:http://gist.github.com/dannysmith/8055495
这没有任何意义 - 如果有人可以解释为什么这似乎修复了错误,那就太好了。也许这是devkit中的一个错误?
答案 1 :(得分:7)
尝试在管理员模式下运行命令提示符。经过7到10个小时,我想出来了......
答案 2 :(得分:7)
我安装了版本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
它解决了Win 7(64位)机器的json 1.6.1特有的问题
答案 3 :(得分:0)
在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页面上没有明确指出。
答案 4 :(得分:0)
我遇到了同样的问题。我使用powershell来检查我的路径
确实,我的红宝石明星不在路上。我在路径中有ruby \ bin但是mingw \ bin位于不同的文件夹下。我进入了我的环境路径并添加了它,我的安装工作正常。PS&GT; $ s = $ env:path
PS&GT; $ s.split(&#34; {;}&#34)
答案 5 :(得分:0)
确保您安装的ruby版本(32或64位)与DevKit版本匹配。他们都必须是32或64,这是我遇到的问题。可能不是这里的确切问题,但我想我会把它扔出去。这是一个值得一试的帖子:
答案 6 :(得分:0)
我如何解决它: