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

时间:2023-01-19 14:29:05

I installed ruby 2.2.0 on Ubuntu 64-bit 14.04 to my home following https://railssavvy.wordpress.com/2012/06/02/install_ruby_and_rails/, and then installed a package called pdfbeads. When I run the package, I have this error:

我按照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>'

To solve the problem, I followed this reply https://*.com/a/19332909/156458,

为了解决这个问题,我按照这个回复https://*.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,

So what happens to ruby and iconv? What shall I do now? Many thanks!

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


I have installed both 2.1.0 and 2.0.0 and pdfbeads under them respectively. But when I run pdfbeads located under their wrappers directories, I still have the same error:

我已经分别安装了2.1.0和2.0.0以及pdfbeads。但是当我运行位于其包装目录下的pdfbeads时,我仍然有同样的错误:

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

2 个解决方案

#1


2  

This error:

这个错误:

ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- iconv (LoadError)

ruby / site_ruby / 2.2.0 / ruby​​gems / core_ext / kernel_require.rb:54:在`require':无法加载这样的文件 - iconv(LoadError)

says that the ruby Standard Library module iconv cannot be found. That's because iconv no longer exists in ruby's Standard Library in ruby 2.2.

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

The line:

这条线:

gem "iconv", "~> 1.0.3"

is supposed to go in a Gemfile, which is a file that is created when you create a rails project. In a rails project, you install all the gems listed in your Gemfile using Bundler, e.g.:

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

$ bundle install

#2


1  

gem install iconv

fixed the issue for me

为我解决了这个问题

#1


2  

This error:

这个错误:

ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- iconv (LoadError)

ruby / site_ruby / 2.2.0 / ruby​​gems / core_ext / kernel_require.rb:54:在`require':无法加载这样的文件 - iconv(LoadError)

says that the ruby Standard Library module iconv cannot be found. That's because iconv no longer exists in ruby's Standard Library in ruby 2.2.

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

The line:

这条线:

gem "iconv", "~> 1.0.3"

is supposed to go in a Gemfile, which is a file that is created when you create a rails project. In a rails project, you install all the gems listed in your Gemfile using Bundler, e.g.:

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

$ bundle install

#2


1  

gem install iconv

fixed the issue for me

为我解决了这个问题