2016-12-06 19 views
0

无法获得Capistrano的3尽量使用或远程服务器rbenv红宝石: Capistrano Version: 3.6.1 (Rake Version: 11.3.0)Capistrano的3不能远程访问服务器上的rbenv红宝石或外壳

/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', 
} 
+0

我不知道,如果这可能是因为你有'ssh_options',检查capistrano-rbenv源代码 - > https://github.com/capistrano/rbenv/blob/master/lib/capistrano/tasks/rbenv.rake – faron

+0

btw你使用的是哪些宝石版本? – faron

+0

@faron在这种情况下,唯一发生变化的是我被要求登录,除了上面列出的问题外,我还看到了一条额外的消息:'文本将以明文回显。请安装HighLine或Termios库以抑制回显文本。' –

回答

0

似乎与Capistrano的和非交互shell,rbenv配置必须放在.bashrc,而不是其他的bash的个人资料文件。

在我的情况,我搬到

export PATH="$HOME/.rbenv/bin:$PATH" 
export TMPDIR="$HOME/tmp" 
eval "$(rbenv init -)" 

.bashrc和解决我的问题。