Ruby gem安装和"没有这样的文件加载"

Fel*_*wer 5 ruby rubygems html-entities

我在Backtrack 5中使用Ruby 1.9.2dev编写脚本但是在尝试使用库"htmlentities"解析html实体时遇到了一些问题.

虽然我已经安装了gem,但我无法加载库.我将向您展示我在控制台中遇到的问题:

root@bt:~# gem list -d htmlentities

*** LOCAL GEMS ***

htmlentities (4.3.1)
    Author: Paul Battley
    Homepage: https://github.com/threedaymonk/htmlentities
    Installed at: /var/lib/gems/1.9.2

    A module for encoding and decoding (X)HTML entities.

root@bt:~# irb  irb(main):001:0> require 'htmlentities'  LoadError: no such file to load -- htmlentities    
       from (irb):1:in `require'    
       from (irb):1     
       from /usr/bin/irb:12:in `<main>'
Run Code Online (Sandbox Code Playgroud)

这与我与nokogiri有同样的问题.我安装了库

gem install htmlentities
Run Code Online (Sandbox Code Playgroud)

你知道我为什么遇到这个问题吗?

谢谢.

编辑:

我还尝试过'require'rubygems'以前的任何其他要求,但是也是这样:

我试过要求'rubygems'但是发生了同样的事情:

irb(main):001:0> require 'rubygems'
=> false
irb(main):002:0> require 'htmlentities'
LoadError: no such file to load -- htmlentities
    from (irb):2:in `require'
    from (irb):2
    from /usr/bin/irb:12:in `<main>'
Run Code Online (Sandbox Code Playgroud)

rob*_*nex 20

尝试require 'rubygems'在其余的宝石要求之前.

rubygems实际上正在重新定义Kernel#require方法以在你的gempath上寻找宝石.Whitout它ruby将只查找本地/路径文件.