“在'require'中:无法加载此类文件 - iconv(LoadError)”

时间:2015-03-23 00:17:33

标签: ruby ubuntu

我在https://railssavvy.wordpress.com/2012/06/02/install_ruby_and_rails/之后将Ubuntu 64位14.04上的ruby 2.2.0安装到我家,然后安装了一个名为pdfbeads的软件包。当我运行包时,我有这个错误:

$ /home/t/.rvm/gems/ruby-2.2.0/wrappers/pdfbeads -o all.pdf
/home/t/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- iconv (LoadError)
    from /home/t/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/t/.rvm/gems/ruby-2.2.0/gems/pdfbeads-1.1.1/bin/pdfbeads:35:in `<top (required)>'
    from /home/t/.rvm/gems/ruby-2.2.0/bin/pdfbeads:23:in `load'
    from /home/t/.rvm/gems/ruby-2.2.0/bin/pdfbeads:23:in `<main>'
    from /home/t/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
    from /home/t/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'

为了解决这个问题,我按照了这个回复https://stackoverflow.com/a/19332909/156458

$ which iconv
/usr/bin/iconv

$ iconv --version
iconv (Ubuntu EGLIBC 2.19-0ubuntu6.6) 2.19
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Ulrich Drepper.

$ gem "iconv", "~> 1.0.3"
ERROR:  While executing gem ... (Gem::CommandLineError)
    Unknown command iconv,

那么ruby和iconv会发生什么?我现在该怎么办?非常感谢!


我已经分别在它们下面安装了2.1.0和2.0.0以及pdfbeads。但是当我在pdfbeads目录下运行wrappers时,我仍然遇到同样的错误:

in `require': cannot load such file -- iconv (LoadError)

2 个答案:

答案 0 :(得分:2)

此错误:

  

红宝石/ site_ruby / 2.2.0 /的rubygems / core_ext / kernel_require.rb:54:在   `require':无法加载这样的文件 - iconv(LoadError)

表示无法找到ruby标准库模块iconv。那是因为在ruby 2.2中ruby的标准库中不再存在iconv

该行:

gem "iconv", "~> 1.0.3"

应该放在Gemfile中,这是一个在创建rails项目时创建的文件。在rails项目中,使用Bundler安装Gemfile中列出的所有gem,例如:

$ bundle install

答案 1 :(得分:1)

gem install iconv

为我解决了这个问题