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

Git Bash Error - Cannot read property 'substring' #272

Closed
johnpittman opened this issue Aug 22, 2015 · 11 comments
Closed

Git Bash Error - Cannot read property 'substring' #272

johnpittman opened this issue Aug 22, 2015 · 11 comments
Labels

Comments

@johnpittman
Copy link

Seems to run on Windows cmd but not Git Bash which sucks because Git Bash is the only sane thing to use on Windows. I had to download ConEmu and use Git Bash from there but now I get a prompt when closing console windows that can't be disabled even though the check-box is unchecked to not confirm. Also somethin'. Nice module.

C:\Users\Admin\Development\Working\package-generator.js\node_modules\inquirer\no de_modules\rx-lite\rx.lite.js:549
throw e;
^
TypeError: Cannot read property 'substring' of undefined
at Interface.rl._getCursorPos (C:\Users\Admin\Development\Working\package-ge nerator.js\node_modules\inquirer\node_modules\readline2\index.js:55:51)
at ScreenManager.render (C:\Users\Admin\Development\Working\package-generato r.js\node_modules\inquirer\lib\utils\screen-manager.js:19:27)
at Prompt.render (C:\Users\Admin\Development\Working\package-generator.js\no de_modules\inquirer\lib\prompts\input.js:75:15)
at Prompt.run (C:\Users\Admin\Development\Working\package-generator.js\node modules\inquirer\lib\prompts\input.js:49:8)
at Prompt.run (C:\Users\Admin\Development\Working\package-generator.js\node
modules\inquirer\lib\prompts\base.js:57:8)
at Object. (C:\Users\Admin\Development\Working\package-generator. js\node_modules\inquirer\lib\ui\prompt.js:83:12)
at module.exports (C:\Users\Admin\Development\Working\package-generator.js\n ode_modules\inquirer\node_modules\run-async\index.js:15:21)
at C:\Users\Admin\Development\Working\package-generator.js\node_modules\inqu irer\lib\utils\utils.js:16:7
at tryCatcher (C:\Users\Admin\Development\Working\package-generator.js\node
modules\inquirer\node_modules\rx-lite\rx.lite.js:537:29)
at setDisposable (C:\Users\Admin\Development\Working\package-generator.js\no de_modules\inquirer\node_modules\rx-lite\rx.lite.js:5380:36)

@SBoudrias
Copy link
Owner

Git Bash is the only sane thing to use on Windows

FWIW, Powershell2 is a good console for Windows environment. If you want more control on the look, wrap it inside Console2. - That was my setup a couple years ago when I was working on ASP projects.

For the bug itself, someone or me is going to take a look eventually. But I don't have a windows machine handy currently, and it's not exactly at the top of my OSS todo list. - If you feel like debugging this one, please do! :)

@SBoudrias SBoudrias added the bug label Aug 22, 2015
@mradionov
Copy link

Have the same issue. The problem is that readline does not consider Git Bash a tty, this.terminal option of the readline instance is being set to false internally, and as I can understand inquirer won't work without tty.

$ node -p -e "Boolean(process.stdout.isTTY)"
false

Git Bash is based on mintty. From mintty docs:

LIMITATIONS

Console issue

Mintty is not a full replacement for the Windows console window that Cygwin uses by default. Like xterm and rxvt, mintty communicates with the child process through a pseudo terminal device, which Cygwin emulates using Windows pipes. This means that native Windows command line programs started in mintty see a pipe rather than a console device. As a consequence, such programs often disable interactive input. Also, direct calls to low-level Win32 console functions will fail. Programs that access the console as a file should be fine though.

See also: nodejs/node-v0.x-archive#6459

That's caused by cygwin's terminal emulation, it's incompatible with node. Closing as WONTFIX. If you feel really strongly about it, you could try your hand at a libuv patch.

Note that you can still use node with cygwin, just not in the mintty terminal.

From my research I do not think that it would be possible to fix it, but I am not competent in this question, maybe @SBoudrias has some ideas. If this is actually unfixable, than the solution would be (for me at least) to check if the process supports tty and respond with a user-friendly error message (maybe it can even be built into inquirer, if it strictly requires tty, I'm not sure).

Some related stuff:

@pumbers
Copy link

pumbers commented Oct 2, 2015

Getting the same problem on Babun ... also mintty based I believe.

@c0b41
Copy link

c0b41 commented Oct 2, 2015

Any update this issue?

@matthewp
Copy link

@ayhankuru What about this comment is not clear enough? #272 (comment)

@c0b41
Copy link

c0b41 commented Oct 18, 2015

@matthewp sorry, ı'm checkout that comment

@SBoudrias
Copy link
Owner

FWIW, that's the issue on Node side tracking the issue you're having nodejs/node#3006

Node always had issue with fake windows command lines. Not sure what their plan is for eventually fixing.

@Danita
Copy link

Danita commented Apr 2, 2016

Puzzlingly enough, I executed node -p -e "Boolean(process.stdout.isTTY)" on my machine but it returned true. My specs:

  • Windows 7 x64
  • Gitbash (which comes with Git for Windows, Mintty ver 2.0.3 x86)
  • Node v5.5.0

I'm here trying to find info to debug this package which depends on Inquirer, and it's failing on said configuration.

@doxxx
Copy link

doxxx commented Apr 11, 2016

I ran across a similar issue and found it worked when running node using winpty in Cygwin's mintty console with the fish shell.

image

Edit: I fail at linking.

@SBoudrias
Copy link
Owner

Please try the latest inquirer version and let me know if that's still an issue.

A lot of work have been done on the Node.js side, and I remove all Inquirer custom readline handling as the Node version is now good enough.

@tiagonapoli
Copy link

When running a .js in git bash, say 'index.js', I got these results:

  • If running using shebang #!/usr/bin/env node, process.stdout.isTTY is undefined.
  • If running using node index.js, process.stdout.isTTY is true

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

No branches or pull requests

9 participants