我正在尝试使用vagrant和chef来在rails应用程序上配置ruby . 我的环境已经设置好,我已经运行了bundler并且已经部署了我的应用程序 . 但是当我尝试使用capistrano运行rake任务时会出现问题 . 我可以通过ssh在发布路径中运行rake任务,但使用capistrano运行相同的命令不起作用 .

下面是我的deploy.rb文件 .

set :application, 'utrippin.API' 
set :repo_url, 'git@bitbucket.org:Jaeren/utrippin.git' 
set :repo_tree, 'utrippin.API'

set :deploy_to, "/u/apps/utrippin.API"
set :scm, :git

set :use_sudo, true

namespace :mysql do

task :create do
on roles :all do
within release_path do
  execute "rake db:create"
end
end
end

end

运行mysql:create task时出现以下错误

SSHKit::Runner::ExecuteError: Exception while executing as vagrant@127.0.0.1: rake db:create exit status: 127
rake db:create stdout: Nothing written
rake db:create stderr: bash: rake: command not found

此外,如果我使用“execute:rake”运行rake命令,db:create“”那么它也会失败,因为它无法在没有密码的情况下连接到mysql数据库,即使在database.yml文件中指定了正确的密码 .

我将非常感谢有关如何使用capistrano运行rake任务的任何帮助,以及为什么我在使用capistrano运行时使用相同用户在同一目录中运行ssh时获得不同结果的原因 .

谢谢 .