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

Using 'list' as the first input to a prompt fails #266

Closed
LPGhatguy opened this issue Aug 3, 2015 · 49 comments
Closed

Using 'list' as the first input to a prompt fails #266

LPGhatguy opened this issue Aug 3, 2015 · 49 comments

Comments

@LPGhatguy
Copy link

Using Inquirer.js 0.9.0 and io.js 2.5.0 or Node 0.12.7 on Windows 10:

var inquirer = require("inquirer");

inquirer.prompt([
    {
        type: "list",
        name: "exampleInput",
        message: "Does this work for you?",
        choices: [
            "Yes",
            "No",
            "I can't tell!"
        ]
    }
], function(answers) {
    console.log("Done!");
});

The arrow keys won't move the menu, allowing selection of only the first choice.

@SBoudrias
Copy link
Owner

Which version of inquirer?

@LPGhatguy
Copy link
Author

Woops, sorry, 0.9.0 from npm

@LPGhatguy
Copy link
Author

Have you been able to reproduce the issue or look into it? I've confirmed that it still occurs on io.js 3.0.0, and I'll be checking it out on Mac OS X this Monday when I stop into work since we're using Inqurier for our new generator system.

What's curious to me is that yo from the yeoman project, which uses Inquirer 0.9.0, doesn't seem to have the same issue despite having the first prompt as a list input.

@SBoudrias
Copy link
Owner

@LPGhatguy does it work with inquirer 0.8.0?

@LPGhatguy
Copy link
Author

@SBoudrias It does not.

@LPGhatguy
Copy link
Author

This bug does not occur on OS X as far as I can tell, so it's probably something Windows specific.

@JCMais
Copy link

JCMais commented Aug 13, 2015

Same issue, it works on node 0.10.40

@leerlemoniii
Copy link

This is still an issue with windows 12 node 4.0.0..... in both command prompt and in powershell

@LPGhatguy
Copy link
Author

Now that node 4.0 is the mainline release, this issue might affect more users.

@SBoudrias
Copy link
Owner

@LPGhatguy I don't have easy access to a windows machine. This seems to be a big issue for you, it'd be nice if you investigate and send a fix as a PR.

@artem-malko
Copy link

@SBoudrias Is there any news?) I have the same problem in Windows 8.1 cmd and git bash.
0.10.0

@SBoudrias
Copy link
Owner

@artem-malko did you try with cmd.exe?

@artem-malko
Copy link

@SBoudrias yeap. And it doesn't work in cmd.exe. I have 3 lists, so, the first one doesn't work, but other are fine.
There is interesting behaviour with firtst list. When I press any button, I see a char from with button in console. It seems, that cmd just output all what I've entered.

@SBoudrias
Copy link
Owner

@artem-malko Looks like windows is not entering in the readline or tty mode...

@artem-malko
Copy link

@SBoudrias so, what can I do or it is a bug of Inquirer?

@SBoudrias
Copy link
Owner

Looks like a Node.js bug. I'd like to have more details to give them to repro, but I don't really have the time to dig this one further.

You should probably investigate the issue on your own (no need to use inquirer, just reproduce it using a Node readline) and report a bug on node.

@maxdow
Copy link

maxdow commented Sep 16, 2015

Yes it's a nodejs bug. I'm able to reproduce it only with readline. It is related to the keypress event that is not triggered correctly

@artem-malko
Copy link

@maxdow so, what can I do with that?

@maxdow
Copy link

maxdow commented Sep 16, 2015

I tried to solve the issue but without success :/ I don't have the time to investigate more before next week. I think the best is to report an issue to node linked to this issue ( the same exist for angular formly and probably somewhere else ) and with a simple reproductible example.

@SBoudrias
Copy link
Owner

@maxdow can you post the steps you took to reproduce here?

@maxdow
Copy link

maxdow commented Sep 17, 2015

I can't have access to my windows machine until Monday. I will post you my test code.
The idea was to detect the keypress event using only readline and nodejs. I had the same result than Inquirer : new line ( press enter ) was Ok but nothing on keydown .
Next i used the keypress module (https://www.npmjs.com/package/keypress) and i was able to make it working.
I'm pretty sure it's a bug from nodejs. Maybe you can try to use keypress in Inquirer.js as a fix but the best it's to find the real problem.

@SBoudrias
Copy link
Owner

I wonder if maybe Node is not detecting the windows cli as a TTY on the first run. We could try to force it in TTY and then try if it still fails for you.

@peterblazejewicz
Copy link

@SBoudrias
We got an input about the issue that maybe somehow will help to trace the problem:
OmniSharp/generator-aspnet#351 (comment)

on the "yo -v" select list, arrows works fine

I'll try to help somehow as that is a core component of generator-aspnet (and probably many others).
Thanks!

@leerlemoniii
Copy link

my very hacky fix for this was to have a regular Y/N question that asked the user if they were ready to run my config.... this then allowed me to make the drop down be the second question. mean user has to hit enter (defaults to yes), but it works after that. I also wrapped this inside a check of if I was on windows so I only add this question if I need to.

@artem-malko
Copy link

@leerlemoniii I did the same thing, but it is not good way)

@peterblazejewicz
Copy link

@SBoudrias
I'm not able to run these examples on my machine at work:
https://github.com/SBoudrias/Inquirer.js/blob/master/examples/checkbox.js
https://github.com/SBoudrias/Inquirer.js/blob/master/examples/list.js
https://github.com/SBoudrias/Inquirer.js/blob/master/examples/long-list.js
https://github.com/SBoudrias/Inquirer.js/blob/master/examples/nested-call.js

node -v: v4.1.0
npm -v: 2.14.3
Inquirer.js: v0.10.0
Windows OS:: 8.1

Tried CMD, Bash and PowerShell terminals.
Let me know where too start with code to debug issue.

@maxdow
Copy link

maxdow commented Sep 22, 2015

done ;)

@artem-malko
Copy link

@maxdow @mzgol @SBoudrias @peterblazejewicz As I understand, we have to wait for new Node release?

@maxdow
Copy link

maxdow commented Sep 22, 2015

Probably, or use a patch with keypress on Inquirer.js ..

@peterblazejewicz
Copy link

@maxdow
just observation: I've got the same problem with keypress - as you described I had to hit Return (Enter) key first to get listener broadcasting keypresses.

@philkunz
Copy link

philkunz commented Dec 3, 2015

any update here?

@SBoudrias
Copy link
Owner

Anyone tried on the latest node? If it's not fixed yet, you should ping them on their bug thread.

@peterblazejewicz
Copy link

@SBoudrias I'll do this with LTS version. Thanks!

@peterblazejewicz
Copy link

@SBoudrias
Tested on Win8.1: it seems that Node 5.1.1 Stable comes with fix.:

PS C:\Users\pibl> node --version
v5.1.1

The 5.1.1 works with CMD and PowerShell terminals. I was not able to get it worked with Bash terminal.
The LTS 4.2.3 version does not contain a fix I think.
Thanks!

@SBoudrias
Copy link
Owner

Bash (like git bash and cie) terminals don't support readlines on Windows. They're very bad emulator.

@peterblazejewicz
Copy link

Bash (like git bash and cie) terminals don't support readlines on Windows. They're very bad emulator.
Understand. Just posting facts for the records. Thanks for the comments!

@peterblazejewicz
Copy link

@LPGhatguy
It seems to be fixed in Node:
nodejs/node#2996

@LPGhatguy
Copy link
Author

It appears to work in 5.3.0 for me -- thanks for pointing that out!

@peterblazejewicz
Copy link

@SBoudrias Thanks for the patience 🙇

@AlexGustafsson
Copy link

Still not working for me. I thought this was solved by the Node JS team?

Windows 10,
CMD & Babun(Cygwin),
Node v5.6.0.

@SBoudrias
Copy link
Owner

There's a regression on the node side. The team is investigating.

@AlexGustafsson
Copy link

@SBoudrias is there any related issue I can follow?

@SBoudrias
Copy link
Owner

nodejs/node#5384

@jokeyrhyme
Copy link

I have a module that helps identify broken versions of Node:

Do you think it might be worth integrating a similar check into this library? So that a warning or something could be displayed? Or perhaps modifying the "engines" part of package.json to help avoid broken Node versions at installation time?

@SmasherCoder
Copy link

Still broken in inquirer 8.2.0 node 16.13.1 on Windows 11 in a Terminal in VS Code

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