capistrano icon indicating copy to clipboard operation
capistrano copied to clipboard

[Windows][Git Bash] `ask` never asks for user input

Open gmichard opened this issue 6 years ago • 3 comments

Tasks

namespace :app do
  desc "Confirmation"
  task :confirmation do
    puts <<-WARN
    ========================================================================
      WARNING: You're about to deploy the branch...
               #{fetch(:branch)}
    ========================================================================
    Are you sure you want to continue? (y/N)
    WARN
    ask :value, "N"

    if fetch(:value) !~ /^y(es)?$/i
      puts "\nDeploy cancelled!"
      exit
    end
  end
end

Expected behavior

When using ask (offcial documentation), the console should wait for user input.

Actual behavior

On Git Bash (Windows), When using ask (offcial documentation) to get user input, the console never stops and automatically uses the default value.

System configuration

$ cap staging doctor

Environment
    Ruby     ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]
    Rubygems 3.0.6
    Bundler  N/A
    Command  D:/ProgramFiles/Ruby24-x64/bin/cap staging doctor

Gems
    capistrano                  3.11.2
    airbrussh                   1.4.0
    rake                        13.0.0          (update available)
    sshkit                      1.20.0
    net-ssh                     5.2.0
    capistrano-composer         0.0.6
    capistrano-file-permissions 1.0.0
    capistrano-symfony          2.0.0.pre.alfa2

gmichard avatar Nov 20 '19 16:11 gmichard

Thanks for the report.

What terminal emulator are you using? I'm extremely unfamiliar with Windows, but I believe options range from cmd.exe, PowerShell (multiple versions?) through Putty and various other things including some cygwin and emulated Linux environments via WSL(2)?

Thanks,

leehambley avatar Nov 20 '19 16:11 leehambley

@leehambley I'm not particullary familiar to Windows too...

Below, this is the use cases that I know, maybe it can enlighten you...

  • :x: The problem occurs when using the "BASH emulation provided by Git for Windows". I don't know what's behind it... Video

  • :x: Same problem, when using ConEmu with this "Startup configuration"

    -cur_console:fp -cur_console:d:D:\Sites\myproject set "PATH=%ProgramFiles%\Git\usr\bin;%PATH%" & "%ProgramFiles%\Git\git-cmd.exe" --no-cd --command=%ConEmuBaseDirShort%\conemu-msys2-64.exe /usr/bin/bash.exe -l -i
    
  • ✔️ But it's OK, when using ConEmu with this "Startup configuration"

    "%ProgramFiles%\Git\git-cmd.exe" --no-cd --command=usr/bin/bash.exe -l -i -new_console:d:D:\Sites\myproject
    

gmichard avatar Nov 21 '19 08:11 gmichard

Seems like either stdin.tty? is returning false or there is an exception being raised and silently caught.

https://github.com/capistrano/capistrano/blob/6e85c69a44db26d1510f7f9117cccfd77df8904a/lib/capistrano/configuration/question.rb#L38-L49

My guess is that it is the tty? thing. Is this possibly the same issue: https://github.com/docker/for-win/issues/1588 ?

mattbrictson avatar Nov 22 '19 01:11 mattbrictson