[英]'Failed to build gem native extension' on Windows 7 (The system cannot find the path specified)
我在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
(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
重要的是C:/bin
和C:/Ruby193/bin
在路徑中。 這意味着當我啟動shell時默認加載ruby 1.9.3並且我可以使用pik use 2.0.0p353
成功切換到2.0.0。 換句話說,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
此時我應該能夠成功運行gem install json —platform=ruby
,但是得到了上面的錯誤。 經過一番挖掘, 我發現了這一點 ,建議檢查COMSPEC是否已設置為corectly並從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。 感謝這篇文章 ,似乎並非如此:
> 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.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
的Makefile 如下所示 。 對我來說這個Makefile甚至被創建似乎很奇怪。
如果任何擁有更多Windows / Ruby經驗的人可以對此有所了解,那就太棒了!
PS。 我在Windows 7 Professional SP1上
所以我想檢查devkit是否正確地使用正確的devkit目錄增強了路徑。 感謝另一個SO問題的建議,我在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確實包括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手動構建。
所以這不是世界上最好的答案,但我似乎偶然發現了一個解決方案。 如果我設置了詳細標志,一切正常:
gem install json --platform=ruby --verbose
這里有一個日志: http : //gist.github.com/dannysmith/8055495
這沒有任何意義 - 如果有人能夠解釋為什么這似乎解決了錯誤,那就太好了。 也許這是devkit中的一個錯誤?
嘗試在管理員模式下運行命令提示符 經過7到10個小時,我想出來了......
我安裝了版本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特有的問題
在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:path
ps> $ s.split(“{;}”)
果然我的紅寶石mingw不在路上。 我在路徑中有ruby \\ bin但是mingw \\ bin位於不同的文件夾下。 我進入我的環境路徑並添加它,我的安裝工作。
確保您安裝的ruby版本(32位或64位)與DevKit版本匹配。 他們都必須是32或64,這是我遇到的問題。 可能不是這里的確切問題,但我想我會把它扔出去。 這是一篇值得一試的帖子:
我是如何修理它的:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.