Thursday, October 28, 2021

[SOLVED] Capistrano "No tty present and no askpass program specified"

Issue

I'm running cap production deploy and I keep getting the following error sudo: no tty present and no askpass program specified after /usr/bin/env sudo mkdir -pv /home/[user]/apps/[app name] as [user@myIP]

I'm not sure how to fix this.

Capfile:

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/migrations'
require 'capistrano/passenger'
require 'capistrano/safe_deploy_to'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

any ideas?


Solution

One solution would be to allow the sudo command on your server without entering a password, but that could be a security risk.

Alternatively, you can fix your Capistrano configuration because something is likely wrong. It would help if you showed us the contents of your deploy.rb file but first thing I would do is ensure that you have default_run_options[:pty] set to true in deploy.rb. Or add the line if you're missing it.

Capistrano 2

default_run_options[:pty] = true

Capistrano 3

set :pty, true


Answered By - Mike S