无法让Capistrano 3使用或远程服务器Rbenv Ruby: Capistrano Version: 3.6.1 (Rake Version: 11.3.0)
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute'
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
SSHKit::Command::Failed: which ruby exit status: 1
which ruby stdout: which: no ruby in (/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin)
which ruby stderr: Nothing written
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/command.rb:100:in `exit_status='
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/backends/netssh.rb:148:in `execute_command'
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute'
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:141:in `tap'
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute'
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:60:in `capture'
config/deploy.rb:88:in `block (4 levels) in <top (required)>'
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:85:in `within'
config/deploy.rb:82:in `block (3 levels) in <top (required)>'
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:29:in `run'
/Users/victorstan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sshkit-1.11.4/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
我的设置:
deploy.rb
set :rbenv_type, :user
set :rbenv_ruby, '1.9.3-p551' # same as in .ruby-version file
set :default_shell, '/bin/bash -l'
set :pty, true
within release_path do
ruby_v = capture("which ruby")
puts "Ruby version: #{ruby_v}"
end
Capfile
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
# Extra rails commands
require "capistrano/rails/collection"
# 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/rvm'
require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
# require 'capistrano/passenger'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
config / deploy / staging.rb
set :ssh_options, {
forward_agent: true,
auth_methods: %w(password),
password: 'xxx',
user: 'xxx',
}
似乎使用Capistrano和非相互作用的外壳,RBENV配置必须放入.bashrc
而不是其他Bash配置文件文件中。
在我的情况下,我移动了
export PATH="$HOME/.rbenv/bin:$PATH"
export TMPDIR="$HOME/tmp"
eval "$(rbenv init -)"
到.bashrc
,这解决了我的问题。