我正在从Peter Cooper的“从初学者到初学者的Ruby”开始学习Ruby。我在第7章。我安装了ruby 2.0。我正面临这个错误:
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- 2.0/redcloth_scan (LoadError)
尝试运行此代码时:
require 'rubygems'
require 'RedCloth'
r = RedCloth.new("This is a *test* of _using RedCloth_")
puts r.to_html
我得到了这个结果:
ruby redcloth.rb
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- 2.0/redcloth_scan (LoadError)
Couldn't load 2.0/redcloth_scan
The $LOAD_PATH was:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib/case_sensitive_require
C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/ext
C:/Ruby200/lib/ruby/site_ruby/2.0.0
C:/Ruby200/lib/ruby/site_ruby/2.0.0/i386-msvcrt
C:/Ruby200/lib/ruby/site_ruby
C:/Ruby200/lib/ruby/vendor_ruby/2.0.0
C:/Ruby200/lib/ruby/vendor_ruby/2.0.0/i386-msvcrt
C:/Ruby200/lib/ruby/vendor_ruby
C:/Ruby200/lib/ruby/2.0.0
C:/Ruby200/lib/ruby/2.0.0/i386-mingw32
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib/RedCloth.rb:13:in `<top (required)>'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from redcloth.rb:2:in `<main>'
Exit code: 1
我已经安装了ruby gems和RedCloth。他们没有给我一个错误。如果有人能够对这一主题有所了解,我们将不胜感激。
答案 0 :(得分:1)
试试这个: 转到C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib 并创建一个名为'2.0'的目录。 然后将redcloth_scan.so从'C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib'复制到'2.0'目录。
答案 1 :(得分:0)
我使用Ruby 1.9.1安装在过去的RedCloth中。 实际上我怀疑RedCloth不能与Ruby 2.0一起使用。
答案 2 :(得分:0)
在ruby 2.x.x上,你需要编译gem。 例如对于windows ruby 2.2.4:
设置DevKit(https://github.com/oneclick/rubyinstaller/wiki/Development-Kit)
运行命令窗口:
gem install RedCloth --platform = ruby
转到已安装的RedCloth路径 LIB \红宝石\宝石\ 2.2.0 \宝石\ RedCloth-4.2.9 \ lib中 在那里创建一个名为“2.2”的新目录,并在其上复制文件redcloth_scan.so。
如果您使用gem RedCloth-4.2.9-x86-mingw32,则redcloth_scan.so包含ruby 1.9依赖项,并且它不适用于ruby 2.2.4。