Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6793249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:04:41+00:00 2026-05-26T18:04:41+00:00

Our team is working on a new application that we started with Rails 3.1

  • 0

Our team is working on a new application that we started with Rails 3.1 and Ruby 1.9.2 – and last night I took it to Ruby 1.9.3.

One of the gems we were using in the dependency chain (css_parser) ended up having a require ‘iconv’ in it, triggering a deprecation warning in 1.9.3 that looked like this:

.../gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require': iconv will be deprecated in the future, use String#encode instead.

At first I naively blamed that on rails without a better trace, until I didn’t find a require ‘iconv’ in it anywhere.

The only way I tracked this down was that I started commenting things out in my Gemfile and then I finally got the bright idea to load irb and start requiring each library in turn. I also could have just done a filesystem grep in the gems directory, but I wasn’t exactly sure that “require ‘iconv'” was what was triggering the error.

What a PITA. There has to be a better way – just doing a –trace in rake tasks that load rails didn’t cut it. Is there some way / any way of triggering a trace on this that would have shown me which line in the relatively long list of library dependencies was triggering the deprecation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:04:42+00:00Added an answer on May 26, 2026 at 6:04 pm

    So, it’s probably a little moot because I’m not likely to ever run into the problem again (and the css_parser gem was the only iconv-requiring gems in my current Rails 3.1/Ruby 1.9.3 projects).

    But it was a puzzle, so I wanted to find some way of solving it.

    The problem is very iconv-specific in this case. There are other ruby deprecations, but for the most part they seem to go through Kernel#warn (if ruby) or rb_warn() (if C) – but the warning in iconv.c is a little different than the others – at any rate it’s a puts to rb_stderr.

    So maybe I can do the following

    1. Override Kernel#require to capture stderr
    2. Check for an iconv message after calling the original Kernel#require
    3. Raise an exception if the message found, thereby getting a trace
    4. Do this before bundler runs if at all possible.

    It turns out I can’t do #4 – because Bundler calls Kernel.require directly – but I can use Bundler to parse the Gemfile to give me a list of things to require myself.

    So this is what I get – thanks to this stack overflow post for a pointer on capturing standard error – and the rubygems source for the idea on aliasing the original Kernel#require

    # override Kernel#require to intercept stderr messages on require
    # and raise a custom error if we find one mentioning 'iconv'
    require "stringio"
    
    class RequireError < StandardError
    end
    
    module Kernel
    
      alias :the_original_require require
      private :the_original_require
    
      def capture_stderr
        # The output stream must be an IO-like object. In this case we capture it in
        # an in-memory IO object so we can return the string value. You can assign any
        # IO object here.
        previous_stderr, $stderr = $stderr, StringIO.new
        yield
        $stderr.string
      ensure
        # Restore the previous value of stderr (typically equal to STDERR).
        $stderr = previous_stderr
      end
    
      def require(name)
        captured_output = capture_stderr do
          the_original_require(name)
        end
    
        if(captured_output =~ %r{iconv})
          raise RequireError, 'iconv requirement found'
        end
      end
    end
    
    require 'bundler'
    
    # load the list of Bundler requirements from the Gemfile
    required_libraries = Bundler.definition.dependencies.map(&:name)
    
    # loop through and require each, ignoring all errors other than
    # our custom error
    
    required_libraries.each do |requirement|
      begin
        require(requirement)
      rescue Exception => e
        if(e.class == RequireError)
          raise e
        end
      end
    end
    

    And voila! A trace message that helps track down where the iconv requirement was.

    In the end, probably just a search for “require ‘iconv'” is still best (once it’s clear that’s the what was causing the error).

    But, as in life. Some Yaks Must Be Shaved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a team working on acceptance testing X11 GUI application in our company,
Our team is creating a new recruitment workflow system to replace an old one.
We're implementing a new solution in our classic ASP environment that's using COM interop
Our team is currently working on completely redesigning our school's website and one of
Or maybe with our implementation of it. I'm new to the team that wants
I and a team-mate are working out an web-based application for our company. SQL
One of our team is working on an ASMX service. The service use to
our development team develops a J2EE application that runs on Weblogic 10.3. Each development
Our team is currently working on a large project which makes heavy use of
Our team has recently been working on a logic and data layer for our

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.