【问题标题】:in `require': no such file to load -- iconv (LoadError)在 `require' 中:没有要加载的文件 -- iconv (LoadError)
【发布时间】:2011-12-11 09:47:06
【问题描述】:
    ➜  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'

我试过安装

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

甚至尝试过Why does installing Nokogiri on Mac OS fail with libiconv is missing?

没有任何作用。请帮忙!

谢谢!

【问题讨论】:

    标签: ruby-on-rails ruby terminal rvm iconv


    【解决方案1】:

    它显示 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.
    

    要解决它,请将其添加到您的 Gemfile 中:

    gem "iconv", "~> 1.0.3"
    

    然后运行bundle install

    注意:iconv 已被弃用一段时间。它被(内置)String#encode
    替换 见这里:https://bbs.archlinux.org/viewtopic.php?id=160369

    【讨论】:

    • 在 Ruby 2.0.0 上指定 iconv gem 对我有用。谢谢!
    • 比重新编译要好得多,这要花很长时间:)
    • 这对我不起作用。我收到错误ERROR: While executing gem ... (Gem::CommandLineError) Unknown command iconv,
    【解决方案2】:

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

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

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

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

    祝你好运

    (附带说明,据报道此错误发生在 Ruby 1.8.7-p3xx 中)

    【讨论】:

      猜你喜欢
      • 2011-11-30
      • 2016-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多