Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool throws an error. #13

Open
vpillinger opened this issue Jun 15, 2018 · 1 comment
Open

Tool throws an error. #13

vpillinger opened this issue Jun 15, 2018 · 1 comment

Comments

@vpillinger
Copy link

vpillinger commented Jun 15, 2018

While trying to run the following command I get an error. I have no idea if this is something wrong my code or a bug in the function. I am running a homestead box in vagrant where I have installed ruby through apt-get. ssh [email protected] 'hostname; uptime' does work.

bundle exec cap staging ssh:doctor --trace

bundle exec cap staging ssh:doctor --trace
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke ssh:doctor (first_time)
** Execute ssh:doctor
** Invoke ssh:config:git (first_time)
** Execute ssh:config:git
** Invoke ssh:config:repo_url (first_time)
** Execute ssh:config:repo_url
** Invoke ssh:config:password (first_time)
** Execute ssh:config:password
** Invoke ssh:config:agent_forwarding (first_time)
** Execute ssh:config:agent_forwarding
** Invoke ssh:local:private_key_exists (first_time)
** Execute ssh:local:private_key_exists
** Invoke ssh:local:agent_running_env_var (first_time)
** Execute ssh:local:agent_running_env_var
** Invoke ssh:local:agent_running_ssh_add (first_time)
** Execute ssh:local:agent_running_ssh_add
4096 SHA256:RfPTmZLA/sLeUxe5Rgn9VgQoTa4fMWJyMRBWUZXFC2o /home/vagrant/.ssh/id_rsa (RSA)
** Invoke ssh:local:repo_access (first_time)
** Execute ssh:local:repo_access
31c638fe5a33d9e40a5c9eee07a94deb9cb76adc        HEAD
... Truncated all of the branches here
ef090b63ca0b772390a1db03cc7c118af20e8733        refs/tags/1.8.9
** Invoke ssh:remote:agent_running (first_time)
** Execute ssh:remote:agent_running
#<Thread:0x000055c0e6d56e50@/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:11 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        8: from /var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
        7: from /var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
        6: from /var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
        5: from /var/lib/gems/2.5.0/gems/capistrano-ssh-doctor-1.0.0/lib/capistrano/tasks/ssh_doctor.rake:87:in `block (4 levels) in <top (required)>'
        4: from /var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:77:in `capture'
        3: from /var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
        2: from /var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
        1: from /var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:129:in `block in _execute'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/formatters/pretty.rb:8:in `write': Exception while executing on host 167.99.230.85: undefined method `<' for nil:NilClass (SSHKit::Runner::ExecuteError)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 167.99.230.85: undefined method `<' for nil:NilClass
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/formatters/pretty.rb:8:in `write'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:129:in `block in _execute'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:77:in `capture'
/var/lib/gems/2.5.0/gems/capistrano-ssh-doctor-1.0.0/lib/capistrano/tasks/ssh_doctor.rake:87:in `block (4 levels) in <top (required)>'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
NoMethodError: undefined method `<' for nil:NilClass
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/formatters/pretty.rb:8:in `write'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:129:in `block in _execute'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:77:in `capture'
/var/lib/gems/2.5.0/gems/capistrano-ssh-doctor-1.0.0/lib/capistrano/tasks/ssh_doctor.rake:87:in `block (4 levels) in <top (required)>'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/var/lib/gems/2.5.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => ssh:remote:agent_running

Here is my staging file

# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary server in each group
# is considered to be the first unless any hosts have the primary
# property set.  Don't declare `role :all`, it's a meta role.

role :app, %w{[email protected]}
role :web, %w{[email protected]}
role :db,  %w{[email protected]}


# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server definition into the
# server list. The second argument is a, or duck-types, Hash and is
# used to set extended properties on the server.

server '167.99.230.85', user: 'runcloud', roles: %w{web app}, my_property: :my_value


# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult[net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start).
#
# Global options
# --------------
set :ssh_options, {
	keys: %w(~/.ssh/id_rsa),
    forward_agent: true,
    auth_methods: %w(password)
}
#
# And/or per server (overrides global)
# ------------------------------------
# server 'example.com',
#   user: 'user_name',
#   roles: %w{web app},
#   ssh_options: {
#     user: 'user_name', # overrides user setting above
#     keys: %w(/home/user_name/.ssh/id_rsa),
#     forward_agent: false,
#     auth_methods: %w(publickey password)
#     # password: 'please use keys'
#   }

And my deploy file

# config valid only for Capistrano 3.1
lock '3.2.1'

set :application, 'my_app_name'
set :repo_url, '[email protected]:roots/bedrock.git'

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

# Default deploy_to directory is /var/www/my_app
# set :deploy_to, '/var/www/my_app'

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
# set :keep_releases, 5

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      # execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :publishing, :restart

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end
@vpillinger
Copy link
Author

vpillinger commented Jun 18, 2018

I have found that removing ALL roles settings has resolved the issue. Its not clear to me why this is causing an issue though.

Update 2:

I fixed this by running bundle update. However, the most recent version on capistrano threw a different error, so I ended up forcing Capistrano version 3.6 and everything runs well now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant