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

KeyError: '0 is not registered' #11

Open
stefangweichinger opened this issue Jan 10, 2023 · 7 comments
Open

KeyError: '0 is not registered' #11

stefangweichinger opened this issue Jan 10, 2023 · 7 comments

Comments

@stefangweichinger
Copy link

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
Copy link
Member

woile commented Sep 14, 2023

Have you tried with the latest versions?

@felipesetti
Copy link

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
Copy link
Member

woile commented Apr 11, 2024

What were you running?

@felipesetti
Copy link

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
Copy link

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
Copy link

bamaas commented Jul 10, 2024

@btsomogyi Have you found a solution for this?

@barracuda156
Copy link

I am getting apparently the same error with a different Python package.

36-141% radian
R version 4.4.2 (2024-10-31) -- "Pile of Leaves"
Platform: powerpc-apple-darwin10.0.0d2 (32-bit)

unexpected error was caught.
please report to https://github.com/randy3k/radian for such error.
[Errno 22] Invalid argument
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py", line 269, in _add_reader
    key = self._selector.get_key(fd)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/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 "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/radian/console.py", line 99, in _read_console
    text = session.prompt(add_history=add_history)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/radian/prompt_session.py", line 71, in prompt
    text = super().prompt(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/radian/lineedit/prompt.py", line 228, in prompt
    result = super().prompt(inputhook=self._inputhook, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1035, in prompt
    return self.app.run(
           ^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 978, in run
    result = loop.run_until_complete(coro)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 886, in run_async
    return await _run_async(f)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 734, in _run_async
    with self.input.raw_mode(), self.input.attach(
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prompt_toolkit/input/vt100.py", line 165, in _attached_input
    loop.add_reader(fd, callback_wrapper)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py", line 344, in add_reader
    self._add_reader(fd, callback, *args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py", line 271, in _add_reader
    self._selector.register(fd, selectors.EVENT_READ,
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/prompt_toolkit/eventloop/inputhook.py", line 112, in register
    return self.selector.register(fileobj, events, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/selectors.py", line 523, in register
    self._selector.control([kev], 0, 0)
OSError: [Errno 22] Invalid argument

Is there any solution?

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

6 participants