rake db:迁移中止!在 US-ASCII 上使用 rake 0.9.2.2 和rails 3.0.10
最近,我升级了 gems,并开始向我的应用程序添加新内容,例如第三方社交网站使用omniauth gem 进行身份验证。在开发环境上一切都很好并且工作起来很有魅力。
我正在使用 capistrano 部署到临时和生产服务器。到目前为止,基本部署很好并且工作正常,但是当我想在部署时进行迁移时,我遇到了非常奇怪的问题。
我从 capistrano 收到以下错误消息:
[my.server.com] executing command
*** [err :: my.server.com] rake aborted!
*** [err :: my.server.com] "\xC5" on US-ASCII
*** [err :: my.server.com]
*** [err :: my.server.com] (See full trace by running task with --trace)
command finished in 2472ms
我到处搜索,找不到任何相关的解决方案。我还尝试将 rake gem 降级回 0.8.7,但最终没有成功 - 同样的错误。
Recently I upgraded my gems and started adding new stuff to my app like authentication by third party social websites using omniauth gem. On development environment everything is fine and works like a charm.
I am deploying to staging and production servers using capistrano. Basic deployment is fine and working so far, but I have got really strange problems when I want to do migrations when deploying.
I get the following error messages from capistrano:
[my.server.com] executing command
*** [err :: my.server.com] rake aborted!
*** [err :: my.server.com] "\xC5" on US-ASCII
*** [err :: my.server.com]
*** [err :: my.server.com] (See full trace by running task with --trace)
command finished in 2472ms
I was googling all around and couldn't find any relevant solution. I also tried to downgrade rake gem back to 0.8.7 but with no success on the end - the same errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过几个小时的谷歌搜索和挖掘后,我找到了(我希望)可能对遇到类似或相同问题的人有所帮助的解决方案。
我在临时服务器上执行了
bundle exec rake --trace db:migrate
并收到以下错误消息:因此我跳入
config/application.rb
文件查找找出什么可能会导致错误。该文件的第 5 行加载一个外部配置文件:并且该外部文件包含 UTF-8 字符,而不是 US-ASCII。所以我尝试了几种不同的解决方案来解决这个问题。
唯一对我有用的是在 config/application.rb 文件顶部添加额外的几行代码:
只是告诉 rake 使用 utf-8 编码加载外部文件。在那次改变之后,一切都很顺利并且完全符合预期。问题解决了!
PS.
我真的不知道为什么 rake 0.9 的开发者改变了 rake 0.8 以前的行为,这对我来说工作得很好,可能对你来说也很长一段时间。也许你知道为什么?我很好奇。
After hours of googling and digging in I found the solution that (I hope) may by helpful for someone with a similar or the same problem.
I did
bundle exec rake --trace db:migrate
on the staging server and got the following error messages:So I jumped in to the
config/application.rb
file to find out what could rise the error. Line 5 of that file loads an external config file:and that external file contains UTF-8 chars, not US-ASCII. So I tried a couple of different solutions to solve that problem.
The only one which worked for me was to add an extra few lines of code on top of
config/application.rb
file:just to tell rake to load external files using utf-8 encoding. After that change everything went smooth and exactly as expected. Problem solved!
PS.
I really don't know why developers of rake 0.9 have changed previous behavior of rake 0.8 which worked fine for me and probably for you as well for a long time. Maybe you have an idea why? I am very curious.