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

[Windows][Git Bash] ask never asks for user input #2042

Open
gmichard opened this issue Nov 20, 2019 · 3 comments
Open

[Windows][Git Bash] ask never asks for user input #2042

gmichard opened this issue Nov 20, 2019 · 3 comments

Comments

@gmichard
Copy link

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
@leehambley
Copy link
Member

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,

@gmichard
Copy link
Author

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

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

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

  • ❌ 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
    

@mattbrictson
Copy link
Member

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

def gets
return unless stdin.tty?
if echo?
stdin.gets
else
stdin.noecho(&:gets).tap { $stdout.print "\n" }
end
rescue Errno::EIO
# when stdio gets closed
return
end

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

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

3 participants