commitizen-tools / commitizen-docker-image

https://hub.docker.com/repository/docker/commitizen/commitizen
MIT License
7 stars 3 forks source link

KeyError: '0 is not registered' #11

Open stefangweichinger opened 1 year ago

stefangweichinger commented 1 year ago

I do my first steps with commitizen and decided to use the docker-image.

In one of my repos I hit errors, now I created a fresh git repo with only one file in it.

I get stuff like:

docker run --rm -v $(pwd):/app -v ~/.gitconfig:/etc/gitconfig -u $(id -u) commitizen/commitizen:latest /bin/sh -c 'cz --debug init'
Warning: Input is not a terminal (fd=0).
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 265, in _add_reader
    key = self._selector.get_key(fd)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/selectors.py", line 192, in get_key
    raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '0 is not registered'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/prompt_toolkit/input/vt100.py", line 176, in _attached_input
    loop.add_reader(fd, callback_wrapper)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 340, in add_reader
    self._add_reader(fd, callback, *args)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 267, in _add_reader
    self._selector.register(fd, selectors.EVENT_READ,
  File "/usr/local/lib/python3.11/selectors.py", line 359, in register
    self._selector.register(key.fd, poller_events)
PermissionError: [Errno 1] Operation not permitted

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/cz", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/commitizen/cli.py", line 407, in main
    args.func(conf, vars(args))()
  File "/usr/local/lib/python3.11/site-packages/commitizen/commands/init.py", line 29, in __call__
    config_path = self._ask_config_path()
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/commitizen/commands/init.py", line 68, in _ask_config_path
    ).ask()
      ^^^^^
  File "/usr/local/lib/python3.11/site-packages/questionary/question.py", line 70, in ask
    return self.unsafe_ask(patch_stdout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/questionary/question.py", line 92, in unsafe_ask
    return self.application.run()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 978, in run
    return loop.run_until_complete(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 885, in run_async
    return await _run_async(f)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 737, in _run_async
    with self.input.raw_mode(), self.input.attach(
  File "/usr/local/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prompt_toolkit/input/vt100.py", line 185, in _attached_input
    raise EOFError
EOFError

context:

sgw in testrepo (main) [🗃️ ×1]  ✗  ls -la
insgesamt 4
drwxr-xr-x.  3 sgw  sgw   80 10. Jän 14:14 .
drwxrwxrwt. 29 root root 700 10. Jän 14:15 ..
drwxr-xr-x.  7 sgw  sgw  220 10. Jän 14:14 .git
-rw-r--r--.  1 sgw  sgw   10 10. Jän 14:14 README.md
sgw in testrepo (main) [🗃️ ×1]  ❯ git status .
Auf Branch main

Noch keine Commits

Zum Commit vorgemerkte Änderungen:
  (benutzen Sie "git rm --cached <Datei>..." zum Entfernen aus der Staging-Area)
    neue Datei:     README.md

This is on a Fedora 37 workstation, if that matters.

I randomly tried that with an older tags of the image, same issues.

Do I have some mistakes in my approach, what can I do? Thanks.

woile commented 11 months ago

Have you tried with the latest versions?

felipesetti commented 4 months ago

I'm having the same issue (kind of intermittent depending on the commit). I am using commitizen image 3.21.3. Any news on that? Tks!

woile commented 4 months ago

What were you running?

felipesetti commented 4 months ago

Not sure I got your question, but will try to give more details. I am running it inside a bamboo agent using the docker image 3.21.3

docker run --rm --volume "$(pwd):/app" --user "$(id -u):$(id -g)" commitizen/commitizen:3.21.3 bump --dry-run

I got the error twice (in different moments). It seems intermitent because If I rerun the pipeline over the same commit it works.

btsomogyi commented 3 months ago

I'm getting this same error with v3.25.0. I have the commit hooks installed as directed here, and when running git commit I get the following error trace:

Traceback (most recent call last):
  File "/Users/btsomogyi/.asdf/installs/python/3.11.5/lib/python3.11/asyncio/selector_events.py", line 265, in _add_reader
    key = self._selector.get_key(fd)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/btsomogyi/.asdf/installs/python/3.11.5/lib/python3.11/selectors.py", line 192, in get_key
    raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '0 is not registered'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/bin/cz", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/lib/python3.11/site-packages/commitizen/cli.py", line 607, in main
    args.func(conf, arguments)()
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/lib/python3.11/site-packages/commitizen/commands/commit.py", line 103, in __call__
    m = self.prompt_commit_questions()
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/lib/python3.11/site-packages/commitizen/commands/commit.py", line 56, in prompt_commit_questions
    answers = questionary.prompt(questions, style=cz.style)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/lib/python3.11/site-packages/questionary/prompt.py", line 78, in prompt
    return unsafe_prompt(questions, answers, patch_stdout, true_color, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/lib/python3.11/site-packages/questionary/prompt.py", line 223, in unsafe_prompt
    answer = question.unsafe_ask(patch_stdout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/lib/python3.11/site-packages/questionary/question.py", line 89, in unsafe_ask
    return self.application.run()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 978, in run
    return loop.run_until_complete(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/btsomogyi/.asdf/installs/python/3.11.5/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 885, in run_async
    return await _run_async(f)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 737, in _run_async
    with self.input.raw_mode(), self.input.attach(
  File "/Users/btsomogyi/.asdf/installs/python/3.11.5/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/Users/btsomogyi/Library/Caches/pypoetry/virtualenvs/commitizen-demo--3a4COU6-py3.11/lib/python3.11/site-packages/prompt_toolkit/input/vt100.py", line 176, in _attached_input
    loop.add_reader(fd, callback_wrapper)
  File "/Users/btsomogyi/.asdf/installs/python/3.11.5/lib/python3.11/asyncio/selector_events.py", line 340, in add_reader
    self._add_reader(fd, callback, *args)
  File "/Users/btsomogyi/.asdf/installs/python/3.11.5/lib/python3.11/asyncio/selector_events.py", line 267, in _add_reader
    self._selector.register(fd, selectors.EVENT_READ,
  File "/Users/btsomogyi/.asdf/installs/python/3.11.5/lib/python3.11/selectors.py", line 522, in register
    self._selector.control([kev], 0, 0)
OSError: [Errno 22] Invalid argument
bamaas commented 1 month ago

@btsomogyi Have you found a solution for this?