如何确认Devkit是否安装成功

系统 1812 0

昨天在安装了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 the config.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) an operating_system.rb file into the relevant directory needed to implement a RubyGems pre_install hook and a devkit.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 目录下, 其他电脑上的路径可能与我的不同 ):

  1. # enable RubyInstaller DevKit usage as a vendorable helper library  
  2. unless ENV[ 'PATH' ].include?( 'd:\\Ruby187\\devkit\\mingw\\bin' ) then  
  3.   puts 'Temporarily enhancing PATH to include DevKit...'  
  4.   ENV[ 'PATH' ] = 'd:\\Ruby187\\devkit\\bin;d:\\Ruby187\\devkit\\mingw\\bin;' + ENV[ 'PATH'
  5. 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 下,其内容相同:

  1. # :DK-BEG: missing DevKit/build tool convenience notice  
  2.  
  3. Gem.pre_install do |gem_installer| 
  4.   unless gem_installer.spec.extensions.empty? 
  5.     have_tools = %w{gcc make sh}.all? do |t| 
  6.       system( "#{t} --version > NUL 2>&1"
  7.     end  
  8.  
  9.     unless have_tools 
  10.       raise Gem::InstallError,<<-EOT 
  11. The '#{gem_installer.spec.name}' native gem requires installed build tools. 
  12.  
  13. Please update your PATH to include build tools or download the DevKit 
  14. from 'http://rubyinstaller.org/downloads' and follow the instructions 
  15. at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'  
  16. EOT 
  17.     end  
  18.   end  
  19. end  
  20. # :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之后,该文件应该为:

  1. Gem.pre_install do |i| 
  2.   unless ENV[ 'PATH' ].include?( 'd:\\Ruby187\\devkit\\mingw\\bin' ) then  
  3.     puts 'Temporarily enhancing PATH to include DevKit...'  
  4.     ENV[ 'PATH' ] = 'd:\\Ruby187\\devkit\\bin;d:\\Ruby187\\devkit\\mingw\\bin;' + ENV[ 'PATH'
  5.   end  
  6. 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.

如何确认Devkit是否安装成功


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论