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

Add pty support for Windows? #561

Open
NathanUrwin opened this issue Aug 3, 2018 · 6 comments
Open

Add pty support for Windows? #561

NathanUrwin opened this issue Aug 3, 2018 · 6 comments

Comments

@NathanUrwin
Copy link

NathanUrwin commented Aug 3, 2018

[MAINTAINER EDIT: this ticket is now about possibly adding pty support for Windows so that really-wants-a-pty-to-behave-right applications can work there. See this comment.]


The example source code line can be found here.

Password for 'https://NathanUrwin@github.com':
You indicated pty=True, but your platform doesn't support the 'pty' module!

Implementing this hotfix (setting pty=False) resulted in the following output:

Password for 'https://NathanUrwin@github.com':
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Password for 'https://NathanUrwin@github.com': No error
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Temp\tmpvrxz271b.py", line 384, in <module>
    main()
  File "C:\Users\user\AppData\Local\Temp\tmpvrxz271b.py", line 379, in main
    PostGenProjectHook().run()
  File "C:\Users\user\AppData\Local\Temp\tmpvrxz271b.py", line 371, in run
    self._git_repo()
  File "C:\Users\user\AppData\Local\Temp\tmpvrxz271b.py", line 328, in _git_repo
    self._git_push()
  File "C:\Users\user\AppData\Local\Temp\tmpvrxz271b.py", line 265, in _git_push
    watchers=watchers,
  File "c:\python37\lib\site-packages\invoke\__init__.py", line 49, in run
    return Context().run(command, **kwargs)
  File "c:\python37\lib\site-packages\invoke\context.py", line 94, in run
    return self._run(runner, command, **kwargs)
  File "c:\python37\lib\site-packages\invoke\context.py", line 101, in _run
    return runner.run(command, **kwargs)
  File "c:\python37\lib\site-packages\invoke\runners.py", line 271, in run
    return self._run_body(command, **kwargs)
  File "c:\python37\lib\site-packages\invoke\runners.py", line 404, in _run_body
    raise UnexpectedExit(result)
invoke.exceptions.UnexpectedExit: Encountered a bad command exit code!

Command: 'git push --set-upstream origin master'

Exit code: 128

Stdout: already printed

Stderr: already printed

Thanks in advance for your time! 🙂

@bitprophet
Copy link
Member

Responder itself should be fine, I think the issue is just the use of pty=True/False - if you look at your first link you'll see comments about how the core issue is code that says pty=True will always fail on Windows. So some code in your stack somewhere is probably setting pty=True.

Is this just a request that we silently change pty=True to pty=False instead of raising an exception? Which would be understandable, though I'm not sure we'd want to do that (certainly, it's not something we can do without backwards compatibility issues). May be worth an opt-in configuration setting like never_use_pty or whatnot.

If it's something else, please let me know!

@NathanUrwin
Copy link
Author

Hey @bitprophet 👋 Thanks for your quick reply!

Sorry I was not clear enough in my original comment! I believe you're correct to say this is specifically a pty issue. The Responder is watching a git push -u origin master command, which I suspect may be writing directly to the local terminal according to the FAQ. Maybe I should change the issue title to Add Windows pty support or similar?

A quick google search yields promising results: winpty and pywinpty 👍

@bitprophet
Copy link
Member

That sounds reasonable to investigate, sure! I don't like having certain behaviors "walled off" for certain platforms, if I can help it.

I suspect that a pile of additional code might be needed to leverage something like pywinpty (basically, it's competing with the simplicity of this chunk here) and I'm also not a big fan of having a lot of additional platform-specific code...so we'll see if those competing desires of mine can come to agreement. Hopefully I'm wrong and it'll only be a few lines of code though.

@bhutch29
Copy link

bhutch29 commented Apr 1, 2020

I use Invoke extensively but the rest of my colleagues use Windows and there are strange failures on Windows platforms for them (commands failing silently and invoke exiting without any console messages). I am holding out hope that these failures are due to the lack of pty support on Windows and would love to see this change come to fruition. I would also be happy to help with the PR, but I am unfortunately out of my element when it comes to programming around terminals/pty/forking etc.

@LuisPeregrinaIBM2
Copy link

winpty, preinstalled in Git Bash, does not fix the issue, it looks like its hardcoded to the OS platform.

@ShaiAvr
Copy link

ShaiAvr commented Nov 1, 2023

Is there any progress on this?
I am using Windows and my tasks can't use colored output like they do when run manually which is very annoying. This limitation is the only thing preventing me from using invoke in my project.

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

5 participants