装好 scruby 后第一次使用遇到一个错误:
site_ruby/1.8/rubygems.rb:246:in `activate': can't activate RubyInline (= 3.6.3), already activated RubyInline-3.6.6] (Gem::Exception)
GOOGLE了一下,找到了两种方法:
1.使用gem uninstall RubyInline把3.6.6版本的RubyInline卸载了,具体操作见lintide的博客。
2.在require 'scrubyt' 之前指定 RubyInline的版本,只要加上以下代码就可以了:
require_gem 'RubyInline', '=3.6.3'
第二种方法在我的linux机器正常,可windows下就报
undefined method `require_gem' for main:Object (NoMethodError)
的错误,可能是我的windows环境里装了最新的rails的缘故,于是把 require_gem 换成 gem,
OK,刚才的错误没了,但是又接着来了新的问题:
Define INLINEDIR or HOME in your environment and try again
检查 $RUBH_HOME\lib\ruby\gems\1.8\gems\RubyInline-3.6.3\lib目录下的 inline.rb 文件,发现里面有这样一段代码:
env = ENV['INLINEDIR'] || ENV['HOME'] if env.nil? then $stderr.puts "Define INLINEDIR or HOME in your environment and try again" exit 1 end
于是就在系统环境变量中添加了 HOME 的设置: HOME=c:\tmp
再次运行代码,上一个错误没有了,又来了一堆新的错误信息:
c:/ruby/lib/ruby/gems/1.8/gems/RubyInline-3.6.3/lib/inline.rb:386:in ``': No s
h file or directory - cl -nologo -LD -MD -Zi -O2b2xg- -G6 -I c:/ruby/lib/rub
1.8/i386-mswin32 -I c:/ruby/include -o "C:\tmp/.ruby_inline/Inline_ParseTree_2
7.so" "C:/tmp/.ruby_inline/Inline_ParseTree_2c97.c" -link /LIBPATH:"c:/ruby/l
" /DEFAULTLIB:"msvcrt-ruby18.lib" /INCREMENTAL:no /EXPORT:Init_Inline_ParseTre
2c97 (Errno::ENOENT)
from c:/ruby/lib/ruby/gems/1.8/gems/RubyInline-3.6.3/lib/inline.rb:386
n `build'
from c:/ruby/lib/ruby/gems/1.8/gems/RubyInline-3.6.3/lib/inline.rb:660
n `inline'
from c:/ruby/lib/ruby/gems/1.8/gems/ParseTreeReloaded-0.0.1/lib/parse_
ee_reloaded.rb:21
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `
m_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `
quire'
from c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.3.4/lib/scrubyt.rb:12
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `
m_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `
quire'
from google.rb:3
这简直是在玩俄罗斯套娃,不同的是这次越到里面娃越大。continue google,发现遇到这个问题的人大有人在,其中有 个叫 cohenyf 的仁兄号称搞定了这个问题,他的解决办法是:
1.把 C:\Program Files\Microsoft Visual Studio\VC98\Bin添加到系统的PATH变量里,当然前提是在你的系统中能找到这个目录。
2.复制windows系统目录下的MSVCP60.DLL 和 C:\Program Files\Microsoft Visual Studio\Common\Bin下的MSPDB60.dll文件到 C:\Program Files\Microsoft Visual Studio\VC98\Bin 下。
3.重启计算机以便 PATH 生效,其实不重启也行的。
我的天,我电脑上没有什么Visual Studio目录,这简直不就是折腾人么,我不玩了,我还是老老实实的继续用我的 beautifulsoap,bye ,scrubyt,我这未还没说句上整话的朋友,不过,等等,有位仁兄提到了什么jscrubyt,
Thanks to Paul Nikitochkin a.k.a. pftg, scRUBYt! made a great leap to ensure win32 compatibility. Paul created JscRUBYt! - the JRuby version of scRUBYt! which should be easy to install under win32 even if you are not a level 64 microsoft compiling ninja (in fact, it requires no compiling, fiddling around with C/C++ or doing anything outside (J)Ruby-land (well, except of installing JRuby, of course)).
说貌似在win32环境跑的很正常,不过要装 jruby,我可不想再试了。
不过,如果你真的在win32下载用scruby,又不想这么折腾自己,那就再装个 0.2.6版吧
gem install scrubyt -v=0.2.6
把代码中的引用代码改成
require 'rubygems' gem 'RubyInline', '=3.6.3' gem 'scrubyt', '=0.2.6' require 'scrubyt'程序总算在windows下跑起来了,不过有多少bug我可不知道,最好还是在linux下用最新版的scrubyt。