为什么我们在命令rake db:migrate
上收到错误Rails Error: Unable to access log file. Please ensure that /home/mahaloo/mahaloo/releases/20120329200051/log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
rake aborted!
unable to open database file
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
那里有什么不对。我尝试通过capistrano部署,我使用本教程设置capistrano http://teachmetocode.com/screencasts/basic-deployment-with-capistrano/
答案 0 :(得分:1)
您要么缺少日志目录或文件。你有没有运行cap deploy:setup?
否则首先手动创建日志文件。
答案 1 :(得分:0)
这可能是因为您遵循不将database.yml检查到源代码管理中的做法。如果是这种情况,您可以在部署shared/config
文件夹中制作database.yml的副本,并创建Capistrano任务以将符号链接返回到您的版本文件夹中。这样的事情(在namespace deploy
)
task :create_symlinks do
run "ln -nfs #{shared_path}/db/production.sqlite3 #{release_path}/db/production.sqlite3"
run " -nfs #{shared_path}/config/ldap.yml #{release_path}/config/ldap.yml"
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
然后在钩子中调用它
after "deploy:finalize_update", "deploy:create_symlinks"
after "deploy:finalize_update", "deploy:migrate"
我认为这样可行,这就是我们如何加强我们的项目。这与以下问题类似:
database.yml deployment best practice Capistrano - can't deploy my database.yml How to manage Rails database.yml
答案 2 :(得分:0)
如果你的环境是在Linux上,你试试sudo
,例如,我在尝试运行迁移时遇到了错误,rake db:migrate
,所以我使用了sudo rake db:migrate
这是有用的,也许是因为试图咨询development.log时的rake没有正确的权限或类似的东西。