Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7hunderbird/5159050 to your computer and use it in GitHub Desktop.
Save 7hunderbird/5159050 to your computer and use it in GitHub Desktop.
Use this to help get rid of the annoying warning when using Ruby 1.9 and you probably have Activesupport.
1. do a `gem env` to get your paths:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2013-02-22 patchlevel 392) [x86_64-darwin12.2.0]
- INSTALLATION DIRECTORY: /Users/deploy/.rbenv/versions/1.9.3-p392-railsexpress/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/deploy/.rbenv/versions/1.9.3-p392-railsexpress/bin/ruby
- EXECUTABLE DIRECTORY: /Users/deploy/.rbenv/versions/1.9.3-p392-railsexpress/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/deploy/.rbenv/versions/1.9.3-p392-railsexpress/lib/ruby/gems/1.9.1
- /Users/deploy/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://rubygems.org/"]
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- http://rubygems.org/
2. Open this folder in your text editor of choice:
subl .
3. Search for the following search term throughout all folders:
require 'iconv'
4. I found that the json-1.7.7 gem has a great algorithm for figuring out how to require 'iconv' or not.
# Shortuct for iconv.
if ::String.method_defined?(:encode) &&
# XXX Rubinius doesn't support ruby 1.9 encoding yet
defined?(RUBY_ENGINE) && RUBY_ENGINE != 'rbx'
then
# Encodes string using Ruby's _String.encode_
def self.iconv(to, from, string)
string.encode(to, from)
end
else
require 'iconv'
# Encodes string using _iconv_ library
def self.iconv(to, from, string)
Iconv.conv(to, from, string)
end
end
5. So I would just pick and choose from my results from the search before and comment out require 'iconv' and replace them with the above.
@btoone
Copy link

btoone commented Mar 15, 2013

Get the gem paths directly:

gem env gempath
gem env gemdir

Search:

cd `gem env gemdir`
grep -rin "require 'iconv'" *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment