我在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
Run Code Online (Sandbox Code Playgroud)
首先,我不是Windows用户,所以这对我来说是一个勇敢的新世界.从工作中继承了一台笔记本电脑,其中有一系列疯狂的图书馆,我已经设法删除所有以前安装的ruby和Devkit,然后安装了以下内容:
C:/Ruby193C:/Ruby200DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe(用于ruby 1x)提取到C:/Ruby193-devkitDevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe(32位用于ruby 2x)提取到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
Run Code Online (Sandbox Code Playgroud)
重要的是这个C:/bin和C:/Ruby193/bin正在路上.这意味着当我启动shell时默认加载ruby 1.9.3并且我可以成功切换到2.0.0 pik use 2.0.0p353.换句话说,pik工作得很好.
Devkit 旨在允许从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
Run Code Online (Sandbox Code Playgroud)
此时我应该能够gem install json —platform=ruby成功运行,但是上面的错误.经过一番挖掘后,我发现了这一点,建议检查COMSPEC是否已设置核心并删除任何AutoRun密钥HKEY_CURRENT_USER\Software\Microsoft\Command Processor- 我有一个来自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
Run Code Online (Sandbox Code Playgroud)
然后我想知道pik是否没有为我选择的特定版本的ruby加载devtools(以及gcc)的版本,并且始终使用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'
Run Code Online (Sandbox Code Playgroud)
(我实际上并没有在窗户上使用猫,但它可以提供更清晰的解释)
正如您所看到的,看起来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
Run Code Online (Sandbox Code Playgroud)
不幸的是,结果日志并没有提供太多的帮助.这就是gem_make.out的样子:
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
Run Code Online (Sandbox Code Playgroud)
我认为这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'
Run Code Online (Sandbox Code Playgroud)
Makefile C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator 看起来像这样.对我来说这个Makefile甚至被创建似乎很奇怪.
如果任何拥有更多Windows/Ruby经验的人可以对此有所了解,那就太棒了!
PS.我在Windows 7 Professional SP1上
所以我想检查devkit是否正确地使用正确的devkit目录增强了路径.感谢另一个SO问题的建议,我在Ruby目录中移动了devkit安装:
tdm devkit现在生活在C:\Ruby193\devkitmingw64居住的地方C:\Ruby200\devkit.运行ruby dk.rb install -f每个devkit后,我打开了两个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
Run Code Online (Sandbox Code Playgroud)
所以看起来它看起来都能正常工作.但:
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
Run Code Online (Sandbox Code Playgroud)
这清楚地告诉我们两件事:
我将看看是否可以使用生成的Makefile手动构建.
dan*_*ith 11
所以这不是世界上最好的答案,但我似乎偶然发现了一个解决方案.如果我设置了详细标志,一切正常:
gem install json --platform=ruby --verbose
Run Code Online (Sandbox Code Playgroud)
这里有一个日志:http://gist.github.com/dannysmith/8055495
这没有任何意义 - 如果有人能够解释为什么这似乎解决了错误,那就太好了.也许这是devkit中的一个错误?
我安装了版本1.8.1的gem json,但是我无法使用json 1.6.1来解决这个问题
gem install json --platform=ruby --verbose
Run Code Online (Sandbox Code Playgroud)
所以,我试试了https://github.com/oneclick/rubyinstaller/issues/184
gem update --system 2.0.3
Run Code Online (Sandbox Code Playgroud)
在那之后
gem install json -v 1.6.1 --platform=ruby --verbose
Run Code Online (Sandbox Code Playgroud)
它为Win 7(64位)机器解决了json 1.6.1特有的问题