iconv will be deprecated in the future, use String#encode instead

diya picture diya · Jun 15, 2012 · Viewed 8.8k times · Source

Am getting the following deprecated warnings with ruby 1.9.3-p125 when i run rspec. But there are no deprecated warnings with ruby 1.9.2.

/gems/ruby-1.9.3-p125@cs/gems/soap4r-1.5.8/lib/xsd/iconvchars
et.rb:9:in `<top (required)>': iconv will be deprecated in the future, use String#encode instead.
/home/ec2-user/.rvm/gems/ruby-1.9.3-p125@cs/gems/hpricot-0.8.2/lib/hpricot/build
er.rb:2:in `require': /gems/ruby-1.9.3-p125@cs/gems/hpricot-0
.8.2/lib/fast_xs.so: undefined symbol: ruby_digitmap - /gems/
ruby-1.9.3-p125@cs/gems/hpricot-0.8.2/lib/fast_xs.so (LoadError)

What could be the cause here? Can someone please help with this.

Answer

dbrumann picture dbrumann · Jun 19, 2012

There is a proposal for ruby 1.9.3 to move stdlibs to gems. As part of this transition transcoding between different string-encodings will be "gemified", see the Wiki (section: What stdlibs should be gemified?).

Therefore every time iconv is called, the deprecation-notice will be shown, in order to notify devs that future versions of ruby won't use lib/iconv and tell them that (and where) a code modification is necessary to account for these planned changes.

For now this is not problematic, as both iconv and String#encode will be supported in order to give devs time to make the transition. but you should keep in mind, that your code will break in future versions if you don't switch out the deprecated code.

A quick Google search will help you make the transition, e.g. "From Iconv#iconv to String#encode", if necessary. if you don't plan to make that change you should stay away from future versions and be extra careful when updating your env.