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

Commitizen installed not able to run command on windows system #1219

Closed
taragurung opened this issue Aug 22, 2024 · 2 comments
Closed

Commitizen installed not able to run command on windows system #1219

taragurung opened this issue Aug 22, 2024 · 2 comments

Comments

@taragurung
Copy link

taragurung commented Aug 22, 2024

Description

I am getting this error when runningcz commit

$ cz commit
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts\cz.exe\__main__.py", line 7, in <module>
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\commitizen\cli.py", line 638, in main
    args.func(conf, arguments)()
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\commitizen\commands\commit.py", line 102, in __call__
    m = self.prompt_commit_questions()
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\commitizen\commands\commit.py", line 55, in prompt_commit_questions
    answers = questionary.prompt(questions, style=cz.style)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\questionary\prompt.py", line 78, in prompt
    return unsafe_prompt(questions, answers, patch_stdout, true_color, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\questionary\prompt.py", line 221, in unsafe_prompt
    question = create_question_func(**_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\questionary\prompts\select.py", line 185, in select
    layout = common.create_inquirer_layout(ic, get_prompt_tokens, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\questionary\prompts\common.py", line 510, in create_inquirer_layout
    ps: PromptSession = PromptSession(
                        ^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\prompt_toolkit\shortcuts\prompt.py", line 476, in __init__
    self.app = self._create_application(editing_mode, erase_when_done)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\prompt_toolkit\shortcuts\prompt.py", line 727, in _create_application
    application: Application[_T] = Application(
                                   ^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\prompt_toolkit\application\application.py", line 282, in __init__
    self.output = output or session.output
                            ^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\prompt_toolkit\application\current.py", line 71, in output
    self._output = create_output()
                   ^^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\prompt_toolkit\output\defaults.py", line 85, in create_output
    return Win32Output(stdout, default_color_depth=color_depth_from_env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\prompt_toolkit\output\win32.py", line 114, in __init__
    info = self.get_win32_screen_buffer_info()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\APR28\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\prompt_toolkit\output\win32.py", line 218, in get_win32_screen_buffer_info
    raise NoConsoleScreenBufferError
prompt_toolkit.output.win32.NoConsoleScreenBufferError: Found xterm, while expecting a Windows console. Maybe try to run this program using "winpty" or run it in cmd.exe instead. Or otherwise, in case of Cygwin, use the Python executable that is compiled for Cygwin.

Steps to reproduce

  1. install commitizen with pip command in Windows 11 Pro
  2. added to environment path was getting warning during installation so
  3. setup a git repo and folder
  4. run cz commit

Current behavior

not able to run cz commit, getting error shown above

Desired behavior

cz commit running as expected

Screenshots

No response

Environment

  • commitizen version: 3.29.0
  • OS: Windows-11
  • python version: Python 3.12.5
@taragurung
Copy link
Author

The problem was it was not supported in other terminal, I was running it in git bash terminal, switched t power-prompt shell and it got working.

@AdrianDC
Copy link
Contributor

For the record, on Windows if you use git-bash or equivalent terminals,
you need a Linux-like TTY for interactive actions and tools,
which is provided by the winpty tool visible in the error log.

Use winpty cz c for example when you see such an error.

For daily usage, some developers may edit their .bashrc :

alias cz='winpty -- cz'

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

No branches or pull requests

2 participants