Rails Capistrano rbenv Puma捆绑:命令未找到

时间:2018-04-03 00:30:57

标签: ruby-on-rails amazon-web-services capistrano rbenv puma

我试图将cap staging deploy运行到AWS实例,这是我们的临时服务器。一切正常,包括捆绑安装...但是当它运行Puma服务器时它失败了:

Command: cd /home/ubuntu/medcordance/current && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.0" RACK_ENV="staging" ; bundle exec puma -C /home/ubuntu/app_name/shared/puma.rb --daemon )

 DEBUG [02658949]   bash: bundle: command not found

我已经检查过高低解决方案。我找不到一个。我运行了gem install bundler,我确认已经安装了bundler,我已经配置了Capistrano,我知道每个设置都应该可以使用,我仍然无法找到解决方案。

Capfile:

# Load DSL and set up stages
require "capistrano/setup"

# Include default deployment tasks
require "capistrano/deploy"

# Load the SCM plugin appropriate to your project:
#
# require "capistrano/scm/hg"
# install_plugin Capistrano::SCM::Hg
# or
# require "capistrano/scm/svn"
# install_plugin Capistrano::SCM::Svn
# or
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#   https://github.com/capistrano/passenger
#
require 'capistrano/rails'
# require "capistrano/rvm"
require "capistrano/rbenv"
require "capistrano/bundler"
# require "capistrano/chruby"
require "capistrano/rails/assets"
require "capistrano/rails/migrations"

require "capistrano/puma"
install_plugin Capistrano::Puma  # Default puma tasks

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

部署:

lock "~> 3.10.1"

set :application, "app_name"
set :repo_url, "my bitbucket"
set :branch, 'master'

set :use_sudo, true

set :rbenv_type, :user
set :rbenv_ruby, '2.5.0'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value

# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp

# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, "/home/ubuntu/app_name"

2 个答案:

答案 0 :(得分:0)

想出来。原来是我的config / deploy.rb文件中的这一行:

set :rbenv_map_bins, %w{rake gem bundle ruby rails}

删除它有用......

答案 1 :(得分:0)

对我来说,将以下行添加到config/deploy.rb

append :asdf_map_ruby_bins, 'puma', 'pumactl' # I use asdf to manage ruby plugins

# Or
# append :rbenv_map_bins, 'puma', 'pumactl' if you're using Rbenv, like OP

解决了问题。希望它能对某人有所帮助!

参考:https://github.com/seuros/capistrano-puma/issues/188

NB * append是Capistrano的新语法,尽管set仍然有效