title: Deploy Rails 2.3.16 application on Heroku, try to migrate database, rake aborted! cannot load such file -- iconv
body: <p>I am trying to deploy a copy of a Rails 2.3.16 application on Heroku. I pushed the application, and added a PostgreSQL database. </p>
  
  <pre><code>heroku run rake db:migrate
  
  rake aborted!
  cannot load such file --iconv
  </code></pre>
  
  <p>Apparently all new applications will run in ruby 2.0.0, and I have been having a lot of trouble managing versions recently. The old applications run in whatever version they were, which is 1.9.2. Maybe that is related. I looked for a long time, and found things such as:</p>
  
  <p><a href="https://stackoverflow.com/questions/16032241/ruby-2-0-iconv-replacement">Ruby 2.0 iconv replacement</a>
  <a href="https://stackoverflow.com/questions/7829886/in-require-no-such-file-to-load-iconv-loaderror">in `require&#39;: no such file to load -- iconv (LoadError) </a></p>
  
  <p>I tried <code>gem install iconv</code></p>
  
  <p>This site doesn't help, or maybe I don't understand what to do:</p>
  
  <p><a href="https://rvm.io/packages/iconv" rel="nofollow noreferrer">https://rvm.io/packages/iconv</a></p>
  
  <p><code>rvm autolibs rvm_pkg</code> did nothing. <code>rvm autolibs enable</code> didn't help.</p>
  
  <p>This site seemed to say something completely different even though it linked to <a href="https://rvm.io/packages/iconv" rel="nofollow noreferrer">https://rvm.io/packages/iconv</a>:</p>
  
  <p><a href="http://bullrico.com/2012/09/04/cannot-load-such-file-iconv/" rel="nofollow noreferrer">http://bullrico.com/2012/09/04/cannot-load-such-file-iconv/</a></p>
  
  <p>I did:</p>
  
  <pre><code>rvm reinstall 1.9.2-p290 --with-iconv-dir=$rvm_path/usr
  </code></pre>
  
  <p>At least 2 things failed in that, and iconv issue is not resolved:</p>
  
  <pre><code>Error running 'env GEM_PATH=/Users/RedApple/.rvm/gems/ruby-1.9.2-p290:/Users/RedApple/.rvm/gems/ruby-1.9.2-p290@global:/Users/RedApple/.rvm/gems/ruby-1.9.2-p290:/Users/RedApple/.rvm/gems/ruby-1.9.2-p290@global GEM_HOME=/Users/RedApple/.rvm/gems/ruby-1.9.2-p290 /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -d /Users/RedApple/.rvm/src/rubygems-2.1.4/setup.rb',
  please read /Users/RedApple/.rvm/log/1379705294_ruby-1.9.2-p290/rubygems.install.log
  Installation of rubygems did not complete successfully.
  
  Error running '__rvm_with ruby-1.9.2-p290 /Users/RedApple/.rvm/scripts/gemsets pristine',
  please read /Users/RedApple/.rvm/log/1379705294_ruby-1.9.2-p290/gemset.pristine-ruby-1.9.2-p290.log
  
  heroku run rake db:migrate
  rake aborted!
  cannot load such file -- iconv
  </code></pre>
  
  <p>I don't have time to reprogram the 2.3.16 application into 3 or 4 if that is required. I don't even know what iconv is. What is the easiest way to get rid of this error?</p>
  
  <p>Edit:</p>
  
  <p>I put this in the Gemfile and redeployed:</p>
  
  <pre><code>ruby '1.9.2'
  </code></pre>
  
  <p>I don't know if it is progress, but now a new error:</p>
  
  <pre><code>heroku run rake db:migrate --trace
  
  ** Invoke db:migrate (first_time)
  ** Invoke environment (first_time)
  ** Execute environment
  rake aborted!
  bad URI(is not URI?): 
  /app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/common.rb:156:in `split'
  /app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/common.rb:174:in `parse'
  /app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/common.rb:628:in `parse'
  /app/config/initializers/redis.rb:1:in `&lt;top (required)&gt;'
  /app/vendor/bundle/ruby/1.9.1/gems/activesupport-2.3.16/lib/active_support/dependencies.rb:173:in `load'
  /app/vendor/bundle/ruby/1.9.1/gems/activesupport-2.3.16/lib/active_support/dependencies.rb:173:in `load_with_new_constant_marking'
  /app/vendor/bundle/ruby/1.9.1/gems/rails-2.3.16/lib/initializer.rb:622:in `block in load_application_initializers'
  /app/vendor/bundle/ruby/1.9.1/gems/rails-2.3.16/lib/initializer.rb:621:in `each'
  /app/vendor/bundle/ruby/1.9.1/gems/rails-2.3.16/lib/initializer.rb:621:in `load_application_initializers'
  /app/vendor/bundle/ruby/1.9.1/gems/rails-2.3.16/lib/initializer.rb:176:in `process'
  /app/vendor/bundle/ruby/1.9.1/gems/rails-2.3.16/lib/initializer.rb:113:in `run'
  /app/config/environment.rb:11:in `&lt;top (required)&gt;'
  /app/vendor/bundle/ruby/1.9.1/gems/activesupport-2.3.16/lib/active_support/dependencies.rb:182:in `require'
  /app/vendor/bundle/ruby/1.9.1/gems/activesupport-2.3.16/lib/active_support/dependencies.rb:182:in `block in require'
  /app/vendor/bundle/ruby/1.9.1/gems/activesupport-2.3.16/lib/active_support/dependencies.rb:547:in `new_constants_in'
  /app/vendor/bundle/ruby/1.9.1/gems/activesupport-2.3.16/lib/active_support/dependencies.rb:182:in `require'
  /app/vendor/bundle/ruby/1.9.1/gems/rails-2.3.16/lib/tasks/misc.rake:4:in `block in &lt;top (required)&gt;'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `call'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in `each'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:597:in `block in invoke_with_call_chain'
  /app/vendor/ruby-1.9.2/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:607:in `block in invoke_prerequisites'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:604:in `each'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:596:in `block in invoke_with_call_chain'
  /app/vendor/ruby-1.9.2/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 levels) in top_level'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top_level'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
  /app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/bin/rake:31:in `&lt;top (required)&gt;'
  /app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `load'
  /app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `&lt;main&gt;'
  </code></pre>
  
  <p>Edit:</p>
  
  <p>I didn't read the error message thoroughly, and missed this line:</p>
  
  <pre><code>/app/config/initializers/redis.rb:1:in `&lt;top (required)&gt;'
  </code></pre>
  
  <p>I commented out these lines, since I don't need Redis yet:</p>
  
  <pre><code># uri = URI.parse( ENV[ "REDISTOGO_URL" ] )
  # REDIS = Redis.new( :host =&gt; uri.host, :port =&gt; uri.port, :password =&gt; uri.password )
  </code></pre>
  
  <p><code>heroku run rake db:migrate</code> finally worked.</p>