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

8.9k views Asked by At

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.

4

There are 4 answers

5
dbrumann On

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.

1
Meier On

The log entry tells you that the problem is generated in the soap4r gem. It looks like the gem was not updated for a while, version 1.5.8 is from year 2007 So it may also have other problems with ruby 1.9.3.

There is a project that claims to have a ruby-1.9 compatible version: soap4r-ruby1.9

There are also other soap libraries for ruby, here you see some of them: ruby-toolbox search for soap

0
muffinista On

Your problem is actually with hpricot, which apparently isn't compatible with ruby 1.9.3, and is throwing the "undefined symbol: ruby_digitmap" you are seeing here. Here's someone else with the same problem.

Unfortunately, hpricot is no longer maintained, so unless someone picks up the mantle, there probably won't be a fix. Your main options would appear to be to stick with ruby 1.9.2, or find an alternative to hpricot. Most people seem to be using nokogiri for XML and HTML parsing in ruby, but there are certainly other options.

0
WebDev On

To remove this warning...

go to your .rvm directory and find iconv.c (mine was at ~/.rvm/src/ruby-1.9.3-p125/ext/iconv/iconv.c)

edit that file are remove or comment out the call to warn_deprecated() (should be near the bottom)

from that file's directory, run ruby extconf.rb then make then make install

Should do the trick