昨天在安裝了Ruby 1.9.2 ,并且將其路徑加入到
Devkit
的
config.yml
中,并且使用
ruby dk.rb install
安裝(不幸的是,沒注意安裝信息)。。但是依然無法構建native gem。于是重裝Ruby,按照devkit的安裝說明來安裝。還是不正確。 Devkit的安裝說明的第4步為Run Installation Scripts:
cd <DEVKIT_INSTALL_DIR>
from Step 3 above.ruby dk.rb init
to generate theconfig.yml
file to be used later in this Step. Your installed Rubies will be listed there (only those installed by a RubyInstaller package are detected at present).- edit the generated
config.yml
file to include installed Rubies not automagically discovered or remove Rubies you do not want to use the DevKit with.- [optional]
ruby dk.rb review
to review the list of Rubies to be enhanced to use the DevKit and verify the changes you made to it are correct.- finally,
ruby dk.rb install
to DevKit enhance your installed Rubies. This step installs (or updates) anoperating_system.rb
file into the relevant directory needed to implement a RubyGemspre_install
hook and adevkit.rb
helper library file into<RUBY_INSTALL_DIR>\lib\ruby\site_ruby
. NOTE: you may need to use the--force
option to update (with backup of the originals) the above mentioned files as discussed at the SFX DevKit upgrade FAQ entry.
在最后一步可知,安裝Devkit其實就是更新了
operating_system.rb
文件,同時新建了
devkit.rb
文件。 在我的電腦上
devkit.rb
已經創建好(Devkit安裝在
D:/Ruby187/devkit
目錄下,
其他電腦上的路徑可能與我的不同
):
- # enable RubyInstaller DevKit usage as a vendorable helper library ?
- unless ENV[ 'PATH' ].include?( 'd:\\Ruby187\\devkit\\mingw\\bin' ) then ?
- ? puts 'Temporarily enhancing PATH to include DevKit...' ?
- ? ENV[ 'PATH' ] = 'd:\\Ruby187\\devkit\\bin;d:\\Ruby187\\devkit\\mingw\\bin;' + ENV[ 'PATH' ]?
- end ?
# enable RubyInstaller DevKit usage as a vendorable helper library unless ENV['PATH'].include?('d:\\Ruby187\\devkit\\mingw\\bin') then puts 'Temporarily enhancing PATH to include DevKit...' ENV['PATH'] = 'd:\\Ruby187\\devkit\\bin;d:\\Ruby187\\devkit\\mingw\\bin;' + ENV['PATH'] end
在Ruby1.9.2中,有兩個
operating_system.rb
文件,分別位于
lib\ruby\site_ruby\1.9.1\rubygems\defaults
和
lib\ruby\1.9.1\rubygems\defaults
下,其內容相同:
- # :DK-BEG: missing DevKit/build tool convenience notice ?
- ?
- Gem.pre_install do |gem_installer|?
- ? unless gem_installer.spec.extensions.empty??
- ??? have_tools = %w{gcc make sh}.all? do |t|?
- ????? system( "#{t} --version > NUL 2>&1" )?
- ??? end ?
- ?
- ??? unless have_tools?
- ????? raise Gem::InstallError,<<-EOT?
- The '#{gem_installer.spec.name}' native gem requires installed build tools.?
- ?
- Please update your PATH to include build tools or download the DevKit?
- from 'http://rubyinstaller.org/downloads' and follow the instructions?
- at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit' ?
- EOT?
- ??? end ?
- ? end ?
- end ?
- # :DK-END: ?
# :DK-BEG: missing DevKit/build tool convenience notice Gem.pre_install do |gem_installer| unless gem_installer.spec.extensions.empty? have_tools = %w{gcc make sh}.all? do |t| system("#{t} --version > NUL 2>&1") end unless have_tools raise Gem::InstallError,<<-EOT The '#{gem_installer.spec.name}' native gem requires installed build tools. Please update your PATH to include build tools or download the DevKit from 'http://rubyinstaller.org/downloads' and follow the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit' EOT end end end # :DK-END:
參考了我電腦上其他版本的Ruby(1.8.7-p334和1.8.7-p330,分別都只有一個
operating_system.rb
),在安裝好Devkit之后,該文件應該為:
- Gem.pre_install do |i|?
- ? unless ENV[ 'PATH' ].include?( 'd:\\Ruby187\\devkit\\mingw\\bin' ) then ?
- ??? puts 'Temporarily enhancing PATH to include DevKit...' ?
- ??? ENV[ 'PATH' ] = 'd:\\Ruby187\\devkit\\bin;d:\\Ruby187\\devkit\\mingw\\bin;' + ENV[ 'PATH' ]?
- ? end ?
- end ?
Gem.pre_install do |i| unless ENV['PATH'].include?('d:\\Ruby187\\devkit\\mingw\\bin') then puts 'Temporarily enhancing PATH to include DevKit...' ENV['PATH'] = 'd:\\Ruby187\\devkit\\bin;d:\\Ruby187\\devkit\\mingw\\bin;' + ENV['PATH'] end end
在修改了
lib\ruby\1.9.1\rubygems\defaults\operating_system.rb
之后,構建native gem時,依然找不到Devkit;但修改
lib\ruby\site_ruby\1.9.1\rubygems\defaults\operating_system.rb
后(不修改
lib\ruby\1.9.1\rubygems\defaults\operating_system.rb
),便可以成功構建。 所以,
如何確認Devkit是否安裝成功呢?
答:檢查
devkit.rb
和
operating_system.rb
文件,其內容應該和上面的內容相同;否則,安裝不成功。
可以手動更改這兩個文件為上面的形式(好像也可以刪除這兩個文件,然后使用
ruby dk.rb install
命令,此時會創建 – 未驗證)。在使用
ruby dk.rb install
時候,需要注意安裝信息或警告,如果某些文件已經存在,可能會跳過。 但是,
為什么在看似“正常”的安裝步驟下,為什么沒能安裝好Devkit?
我沒有找到原因;或許我的某個步驟有問題。我發現,雖然我安裝的是1.9.2,但是卻被安裝在了
lib\ruby\1.9.1
目錄下,
官方解釋
說:
This version is a “library compatible version.” Ruby 1.9.2 is almost 1.9.1 compatible, so the library is installed in the 1.9.1 directory.
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
