2

我正在尝试在 ruby​​ 1.9.3 上安装 iconv (gem),但是运行时失败:

宝石安装图标v

Building native extensions.  This could take a while...
ERROR:  Error installing iconv:
    ERROR: Failed to build gem native extension.

        /home/adhown/.rbenv/versions/1.9.3-p0/bin/ruby extconf.rb
checking for iconv() in iconv.h... yes
checking for const of iconv() 2nd argument... no
creating Makefile

make
compiling iconv.c
In file included from iconv.c:21:0:
/home/adhown/.rbenv/versions/1.9.3-p0/include/ruby-1.9.1/ruby/backward/st.h:2:2: warning: #warning use "ruby/st.h" instead of bare "st.h" [-Wcpp]
iconv.c:22:20: fatal error: intern.h: No such file or directory
compilation terminated.
make: *** [iconv.o] Error 1


Gem files will remain installed in /home/adhown/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/iconv-0.1 for inspection.
Results logged to /home/adhown/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/iconv-0.1/ext/iconv/gem_make.out

我用 rbenv 安装 ruby​​ 是否相关?

谁知道怎么解决,谢谢。

4

1 回答 1

0

删除 iconv gem 并使用 String#encode 代替。

这将返回 my_string_variable utf-8 编码的字符串副本:

my_string_variable.encode('utf-8', {:invalid => :replace, :undef => :replace, :replace => ''})    

参见:Ruby-Doc

于 2015-01-15T10:50:10.130 回答