iconv deprecation warning with ruby 1.9.3

后端 未结 5 2197
小鲜肉
小鲜肉 2020-12-13 13:02

I\'m getting this warning when I run rspec:

/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require\': iconv will be deprecated in          


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 14:01

    If you're seeing this, it's very probably not Rails. If you look at the method surrounding the line being referred to in the error you posted, you'll see the following:

    def require(file, *)
      result = false
      load_dependency(file) { result = super }
      result
    end
    

    I'm not saying it's your code, necessarily, but I'm certain that it's not actually the line in question where iconv is being called. In my case, I found that my project's code actually contained a reference to iconv.

    If you want to check your code for such a reference, try grep -ir iconv ./ in your project directory.

    When iconv is actually in a library it can be harder to find. By temporarily changing the above method to:

    def require(file, *)
      result = false
      puts
      puts caller.reverse
      load_dependency(file) { result = super }
      result
    end
    

    You can then easily run your code and grep out the relevant lines of the backtrace to find the root cause of the warning.

    ruby your/code.rb 2>&1 | grep -B 5 iconv
    

提交回复
热议问题