1

我正在从 Peter Cooper 的“Beginning Ruby from Novice to Professional”中学习 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。他们没有给我一个错误。如果有人能对这个话题有所了解,将不胜感激。

4

3 回答 3

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' 目录中。

于 2014-08-21T09:23:10.563 回答
0

我过去用 Ruby 1.9.1 安装了 RedCloth。实际上我怀疑 RedCloth 不适用于 Ruby 2.0。

于 2014-08-21T15:24:27.710 回答
0

在 ruby​​ 2.xx 上,您需要编译 gem。例如对于 windows ruby​​ 2.2.4:

设置 DevKit ( https://github.com/oneclick/rubyinstaller/wiki/Development-Kit )

运行到命令窗口:

宝石安装 RedCloth --platform=ruby

转到您安装的 RedCloth 路径 lib\ruby\gems\2.2.0\gems\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。

于 2016-05-02T12:49:32.250 回答