在“require”中:没有要加载的此类文件——iconv (LoadError)

时间:2023-01-19 13:55:37
    ➜  expertiza git:(master) ✗ ruby -v
    ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.1.0]
    ➜  expertiza git:(master) ✗ rails -v
    Rails 2.3.14
    ➜  expertiza git:(master) ✗ script/server
/Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/inflector.rb:3:in `require': no such file to load -- iconv (LoadError)
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/inflector.rb:3
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext/integer/inflections.rb:1:in `require'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext/integer/inflections.rb:1
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext/integer.rb:2:in `require'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext/integer.rb:2
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext.rb:8:in `require'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext.rb:8
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext.rb:8:in `each'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/core_ext.rb:8
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support.rb:56:in `require'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support.rb:56
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.14/lib/commands/server.rb:1:in `require'
    from /Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.14/lib/commands/server.rb:1
    from script/server:3:in `require'

I have tried installing

我有试着安装

rvm pkg install readline
rvm pkg install iconv
rvm install 1.8.7
rvm use 1.8.7 

Even tried Why does installing Nokogiri on Mac OS fail with libiconv is missing?.

甚至尝试过为什么在Mac OS上安装Nokogiri失败了?

Nothing works. Please help!

没有什么工作。请帮助!

Thanks!

谢谢!

2 个解决方案

#1


31  

It shows that the iconv not exist but the iconv has installed in my production env.

它表明,iconv不存在,但iconv已经安装在我的生产环境中。

root@AY130/current# iconv --version
iconv (Ubuntu EGLIBC 2.15-0ubuntu10.4) 2.15
Copyright (C) 2012 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.

To resolve it, add this in your Gemfile:

要解决这个问题,请将其添加到您的Gemfile中:

gem "iconv", "~> 1.0.3"

Then run bundle install.

然后运行包安装。

Note: iconv has been deprecated for a while. It is replaced by (builtin) String#encode
See here: https://bbs.archlinux.org/viewtopic.php?id=160369

注意:iconv已经被弃用一段时间了。它被(内置)字符串#编码所取代,参见这里:https://bbs.archlinux.org/viewtopic.php?id=160369

#2


6  

For those using rbenv instead of rvm

对于那些使用rbenv而不是rvm的人

$ which iconv
$ /usr/local/bin/iconv

Then use the directory location of iconv to reinstall ruby

然后使用iconv的目录位置重新安装ruby

$ CONFIGURE_OPTS="--with-iconv-dir=/usr/local" rbenv install 1.8.7-p358

Good luck

祝你好运

(As a side note, this error has been reported to happen in Ruby 1.8.7-p3xx)

(顺便说一句,这个错误在Ruby 1.8.7-p3xx中发生过)

#1


31  

It shows that the iconv not exist but the iconv has installed in my production env.

它表明,iconv不存在,但iconv已经安装在我的生产环境中。

root@AY130/current# iconv --version
iconv (Ubuntu EGLIBC 2.15-0ubuntu10.4) 2.15
Copyright (C) 2012 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.

To resolve it, add this in your Gemfile:

要解决这个问题,请将其添加到您的Gemfile中:

gem "iconv", "~> 1.0.3"

Then run bundle install.

然后运行包安装。

Note: iconv has been deprecated for a while. It is replaced by (builtin) String#encode
See here: https://bbs.archlinux.org/viewtopic.php?id=160369

注意:iconv已经被弃用一段时间了。它被(内置)字符串#编码所取代,参见这里:https://bbs.archlinux.org/viewtopic.php?id=160369

#2


6  

For those using rbenv instead of rvm

对于那些使用rbenv而不是rvm的人

$ which iconv
$ /usr/local/bin/iconv

Then use the directory location of iconv to reinstall ruby

然后使用iconv的目录位置重新安装ruby

$ CONFIGURE_OPTS="--with-iconv-dir=/usr/local" rbenv install 1.8.7-p358

Good luck

祝你好运

(As a side note, this error has been reported to happen in Ruby 1.8.7-p3xx)

(顺便说一句,这个错误在Ruby 1.8.7-p3xx中发生过)