Ruby gem install和“No such file to load” [英] Ruby gem install and "No such file to load"

查看:116
本文介绍了Ruby gem install和“No such file to load”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我无法加载库,尽管我已经安装了它的宝石。
我会告诉你我在控制台中遇到的问题:

  root @ bt:〜#gem list -d htmlentities 

***本地GEMS ***

htmlentities(4.3.1)
作者:Paul Battley
主页:https: //github.com/thdayaymonk/htmlentities
安装位置:/var/lib/gems/1.9.2

用于编码和解码(X)HTML实体的模块。

root @ bt:〜#irb irb(main):001:0>需要'htmlentities'LoadError:没有这样的文件加载 - htmlentities $ b $从(irb):1:在'require'$ b $ from(irb):1 $ b $ from / usr / bin / irb :12:在< main>'

这个问题与nokogiri相同。我安装了

  gem install htmlentities 

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



谢谢。

编辑:

我曾尝试过require'rubygems'以前的任何其他要求,但发生相同的情况:



我试过要求'rubygems',但情况相同:

  irb(main):001:0>要求'rubygems'
=> false
irb(main):002:0>需要'htmlentities'
LoadError:没有这样的文件要加载 - htmlentities $(bb)来自(irb):2:'require'
来自(irb):2
来自/ usr / bin / irb:12:在< main>中


解决方案

在其他宝石需求之前,尝试 require'rubygems'>。

ruby​​gems实际上是重新定义了 Kernel#require 方法来查找gempath上的gem。 Whitout它红宝石只会寻找本地/路径文件。


I'm scripting with Ruby 1.9.2dev in Backtrack 5 but I'm having some problems when try to parse html entities with the library "htmlentities".

I cannot load the library although I have installed it with gem. I'll show you the problems I'm having in the console:

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>'

This is the same problem I'm having with nokogiri. I installed the library with

gem install htmlentities

Do you have any idea why I'm having this problem?

Thank you.

EDITED:

I tried also with require 'rubygems' previously to any other require, but happens the same:

I tried require 'rubygems' but is happening the same:

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>'

解决方案

Try to require 'rubygems' before the rest of your gems requirements.

rubygems is actually redefining the Kernel#require method to look for gems on your gempath. Whitout it ruby will just look for local/on path files.

这篇关于Ruby gem install和“No such file to load”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆