需要 yajl 时发生 LoadError

发布于 2024-09-08 22:10:50 字数 1135 浏览 7 评论 0原文

我已经在 ubuntu 10.04 安装上安装了 yajl、libyajl-dev 和 yajl-ruby gem。

我将 gem 添加到了 2.3.8 ruby​​ on Rails 安装中,因为 2.3.6 的发行说明表明如果系统中存在 yajl 将被使用。 Rails 会显示一条错误消息,类似于“无法加载 yajl-ruby”,所以我想我会看到 irb 会话中发生了什么。发生的事情是这样的:

$ dpkg -l | grep yajl
ii  libyajl-dev                       1.0.8-1                                         Yet Another JSON Library - development files
ii  libyajl1                          1.0.8-1                                         Yet Another JSON Library
ii  yajl-tools                        1.0.8-1                                         Yet Another JSON Library - tools
$ gem list | grep yajl
yajl-ruby (0.7.6)
$ irb 
> require 'yajl'
LoadError: no such file to load -- yajl
        from (irb):1:in `require'
        from (irb):1
        from :0
> require 'yajl/gzip'
LoadError: no such file to load -- yajl/gzip
        from (irb):2:in `require'
        from (irb):2
        from :0
> require 'yajl-ruby'
LoadError: no such file to load -- yajl-ruby
        from (irb):3:in `require'
        from (irb):3
        from :0

在花了一段时间搜索这个问题后,我找不到其他人遇到这个问题。有人知道发生了什么事吗?

I have installed yajl, libyajl-dev, and the yajl-ruby gem on a ubuntu 10.04 installation.

I added the gem to a 2.3.8 ruby on rails installation since the release notes for 2.3.6 indicated that yajl would be used if present in the system. Rails bails with an error message along the lines of 'unable to load yajl-ruby' so I thought I would see what is happening in an irb session. This is what happens:

$ dpkg -l | grep yajl
ii  libyajl-dev                       1.0.8-1                                         Yet Another JSON Library - development files
ii  libyajl1                          1.0.8-1                                         Yet Another JSON Library
ii  yajl-tools                        1.0.8-1                                         Yet Another JSON Library - tools
$ gem list | grep yajl
yajl-ruby (0.7.6)
$ irb 
> require 'yajl'
LoadError: no such file to load -- yajl
        from (irb):1:in `require'
        from (irb):1
        from :0
> require 'yajl/gzip'
LoadError: no such file to load -- yajl/gzip
        from (irb):2:in `require'
        from (irb):2
        from :0
> require 'yajl-ruby'
LoadError: no such file to load -- yajl-ruby
        from (irb):3:in `require'
        from (irb):3
        from :0

I cannot find anyone else with this problem after spending a while searching for this issue. Anyone have any idea what is going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抹茶夏天i‖ 2024-09-15 22:10:50

使用 gem 代替 sudo gem install yajl-ruby

然后像 ruby​​ 脚本中的任何其他 gem 一样使用它

require 'rubygems'
require 'yajl'

json = File.new('test.json', 'r')
parser = Yajl::Parser.new
hash = parser.parse(json)

Use the gem instead sudo gem install yajl-ruby

Then just use it like any other gem in your ruby script

require 'rubygems'
require 'yajl'

json = File.new('test.json', 'r')
parser = Yajl::Parser.new
hash = parser.parse(json)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文