2

我正在尝试在 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。也许这有关系。找了半天,找到了这样的东西:

“require”中的Ruby 2.0 iconv 替换 :没有要加载的文件 -- 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终于奏效了。

4

1 回答 1

2

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

ruby '1.9.2'

经验教训:如果您有一个旧应用程序需要在 Heroku 上重新部署以用于其他目的,您需要在 Gemfile 中指定 ruby​​ 版本。

于 2013-09-20T20:16:59.530 回答