Capistrano 3和Rbenv使用Chef在系统范围内安装(bash: bundle: command未找到)



我的Capfile

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/migrations'
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
Rake::Task[:production].invoke

我的部署。rb文件

    set :application, 'mmweb'
    set :scm,           :git
    set :repo_pwd, "Fischer"
    set :repo_url, "https://hash_bush:#{fetch(:repo_pwd)}@bitbucket.org/hash_bush/mm-server.git"
    set :migrate_target,  :current
    set :ssh_options, {:user => 'vagrant',keys: ['C:/Users/hrr/Desktop/insecure_private_key']}
    set :rails_env,       "development"
    set :deploy_to,       "/var/www/mm/"
    set :default_environment, {
    'PATH' => "/opt/rbenv/shims:/opt/rbenv/bin:$PATH"
   }
    set :rbenv_ruby, '1.9.2-p320'
    set :rbenv_path, "/opt/rbenv"
    set :use_sudo, true
    set :log_level, :debug
    set :linked_files, %w{config/database.yml}
    set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
    set :keep_releases, 1
    task :migrate do
     on roles(:web) do
        puts current_path
        puts shared_path
        puts execute "pwd"
        execute "cd #{current_path}/mm-web && rm -rf Gemfile.lock"
        execute "cd #{current_path}/mm-web && bundle exec install"
        execute "bundle exec rake:db migrate"
        #execute "cd #{current_path}/mm-api && rake db:migrate"
        #execute "bundle install"
      end  
      end

    task :restart do
      on roles(:web), in: :sequence, wait: 1 do
         execute "sudo /etc/init.d/nginx restart"
      end
    end
    after :deploy, :migrate

在执行cap deploy和cd #{current_path}/mm-web &&Bundle exec install我得到

cd/var/www/mm/current/mm-web &&Bundle exec install stderr: bashBundle:逗号未找到

我的部署机器rbenv在/opt/rbenv/垫片

不仅bundle命令rake也不工作。我知道这和我的人生道路有关。我真的被这个问题困住了。请帮助。

试试这个表单

task :migrate do
  on roles(:web) do
    within release_path do
      execute 'bundle', 'exec rake db:migrate'
    end
  end
end

最新更新