Ruby学习札记(9) - 解决rake doc:guides出错问题
根据Getting Started with Rails上的
Runningrake doc:guides will put a full copy of the Rails Guides in the doc/guidesfolder of your application. Open doc/guides/index.html in your web browser toexplore the Guides
可以生成一份离线版的Rails Guides。
但是rake doc:guides总是报错,一路错误重重走过来,于是做个笔记here。
(1)准备工作
ruby –v ruby 1.9.2p290 (2011-07-09) [i386-mingw32] rails –v Rails 3.1.0 gem –v 1.8.10基本我的配置是这样的,新建一个rails工程。cd到新的工程根目录下,敲入rake doc:guides命令后,报错接踵而来……
(2)Error1:no such file to load – redcloth(没有”RedCloth” gem)
rake aborted! no such file to load -- redcloth C:/MyProgramFiles/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0/guides/rails_g uides.rb:27:in `require' C:/MyProgramFiles/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0/guides/rails_g uides.rb:27:in `<top (required)>' ……解决方法:安装redcloth,使用命令:gem install RedCloth,注意:gem名区分大小写。
(3)Error2:Failed to build gem native extension(没有DevKit编译RedCloth)
ERROR: Error installing RedCloth: ERROR: Failed to build gem native extension.解决方法:去 https://github.com/oneclick/rubyinstaller上下载DevKit,我用的是DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe。按照 https://github.com/oneclick/rubyinstaller/wiki/Development-Kit上的说明,就可以正确安装好。
(4)Error3:no such file to load – redcloth(Gemfile没有加入RedCloth)
no such file to load -- redcloth C:/MyProgramFiles/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0/guides/rails_g uides.rb:27:in `require' C:/MyProgramFiles/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0/guides/rails_g uides.rb:27:in `<top (required)>' ……解决方法:修改Gemfile,添加一行“gem 'RedCloth', :require => 'redcloth'”
(5)Error4:no such file to load -- 1.9/redcloth_scan (RedCloth的Bug吧:()
rake aborted! no such file to load -- 1.9/redcloth_scan Couldn't load 1.9/redcloth_scan The $LOAD_PATH was: ……解决方法:敲入“bundle show RedCloth”命令,查看RedCloth的安装位置,在其lib目录下新建一个目录名为“1.9”,并将lib/redcloth_scan.so复制到“1.9”目录下。
(6)Success:rake doc:guides成功后,生成doc/guides目录以及html等文件,OK!
D:\workruby\blog>rake doc:guides (in D:/workruby/blog) Generating 2_2_release_notes.html Generating 2_3_release_notes.html Generating 3_0_release_notes.html Generating 3_1_release_notes.html Generating action_controller_overview.html Generating action_mailer_basics.html Generating action_view_overview.html ……
参考资料:
1、https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
2、http://stackoverflow.com/questions/7249433/redcloth-is-breaking-my-rails-3-blog
3、http://stackoverflow.com/questions/7290868/how-to-install-redcloth-on-windows