在Heroku上部署Rails 2.3.16应用程序,尝试迁移数据库,rake中止!无法加载此类文件 - iconv

时间:2013-09-20 19:40:59

标签: ruby-on-rails ruby heroku

我正在尝试在Heroku上部署Rails 2.3.16应用程序的副本。我推送了应用程序,并添加了PostgreSQL数据库。

heroku run rake db:migrate

rake aborted!
cannot load such file --iconv

显然所有新应用程序都将在ruby 2.0.0中运行,而且我最近在管理版本方面遇到了很多麻烦。旧的应用程序以任何版本运行,即1.9.2。也许那是相关的。我找了很久,找到了诸如以下的东西:

Ruby 2.0 iconv replacement in `require': no such file to load -- iconv (LoadError)

我尝试了gem install iconv

这个网站没有帮助,或者我可能不明白该怎么做:

https://rvm.io/packages/iconv

rvm autolibs rvm_pkg什么也没做。 rvm autolibs enable没有帮助。

这个网站似乎说了一些完全不同的内容,即使它链接到https://rvm.io/packages/iconv

http://bullrico.com/2012/09/04/cannot-load-such-file-iconv/

我做了:

rvm reinstall 1.9.2-p290 --with-iconv-dir=$rvm_path/usr

至少有两件事失败了,而且iconv问题没有解决:

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

如果需要,我没有时间将2.3.16应用程序重新编程为3或4。我甚至不知道iconv是什么。摆脱这个错误的最简单方法是什么?

编辑:

我把它放在Gemfile中并重新部署:

ruby '1.9.2'

我不知道它是否有进展,但现在出现了新的错误:

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 `<top (required)>'
/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 `<top (required)>'
/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 <top (required)>'
/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 `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `load'
/app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `<main>'

编辑:

我没有彻底阅读错误消息,错过了这一行:

/app/config/initializers/redis.rb:1:in `<top (required)>'

我评论了这些内容,因为我还不需要Redis:

# uri = URI.parse( ENV[ "REDISTOGO_URL" ] )
# REDIS = Redis.new( :host => uri.host, :port => uri.port, :password => uri.password )

heroku run rake db:migrate终于奏效了。

1 个答案:

答案 0 :(得分:2)

所有这一切,似乎主要问题是通过将这一行添加到Gemfile来解决的:

ruby '1.9.2'

获得的经验:如果你有一个旧的应用程序需要在Heroku上为其他目的重新部署,你需要在Gemfile中指定ruby版本。