Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run `cz init` will raise `UnicodeDecodeError`

See original GitHub issue


The cz init command may fail unexpectedly under some condition.
In this case, the error may be caused by my command output is not encoding by UTF-8. I have tried to decode the output using CP950 and after that I can see a error message: 'pre-commit' 不是內部或外部命令、可執行的程式或批次檔。, which means that PowerShell can not find pre-commit to execute, because I forget to install it before run cz init.

Steps to reproduce

  1. Create a empty directory
  2. Enter the directory
  3. execute cz init and use the default setttings

Current behavior

It will raise UnicodeDecodeError, logs are attached below:

? Please choose a supported config file: (default: pyproject.toml) pyproject.toml
? Please choose a cz (commit rule): (default: cz_conventional_commits) cz_conventional_commits
No Existing Tag. Set tag to v0.0.1
? Please enter the correct version format: (default: "$version")
? Do you want to install pre-commit hook? Yes
Traceback (most recent call last):
  File "c:\users\aa\appdata\local\programs\python\python38\lib\", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\aa\appdata\local\programs\python\python38\lib\", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\AA\AppData\Local\Programs\Python\Python38\Scripts\cz.exe\", line 7, in <module>
  File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\", line 301, in main
    args.func(conf, vars(args))()
  File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\commands\", line 43, in __call__
  File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\commands\", line 144, in _install_pre_commit_hook
    c ="pre-commit install --hook-type commit-msg")
  File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\", line 23, in run
    return Command(stdout.decode(), stderr.decode(), stdout, stderr, return_code)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa4 in position 13: invalid start byte

Desired behavior

Successfully initialize commitizen project.


  • commitizen version: 2.18.1
  • python version: 3.8.7
  • operating system: Windows (OS buid: 19043.1237)
  • shell: PowerShell 7.1.3

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

Bogaycommented, Aug 7, 2022

No problem.

woilecommented, Aug 7, 2022

That makes sense. If you say “Yes I want pre-commit” and cz fails to install/configure it, then it shouldn’t pass silently. The user must fix pre-commit first and then continue with cz. Do you think you can submit a PR?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Contribute to commitizen-tools/commitizen - GitHub
`cz` commands failed if there is already a config file but in wrong ... Run `cz init` will raise `UnicodeDecodeError` bug help wanted...
Read more >
iotop can raise UnicodeDecodeError because /proc/pid/status ...
Sometimes iotop fails with following error: $ sudo iotop. Traceback (most recent call last): File "/usr/sbin/iotop", line 17, in <module>
Read more >
Connection to MySql server fails - Python - Stack Overflow
I'm trying to connect to mySql database using Python. The database is situated on free webhosting server I use mysql.connector.
Read more >
subject:"\[Bug 1932523\] Re\: iotop can raise UnicodeDecodeError ...
Changed in: iotop (Debian) Status: Unknown => Confirmed -- You received this bug notification because you are a member of Ubuntu Bugs, which...
Read more >
Init - Commitizen
For new projects, it is possible to run cz init . This command will prompt the user for information about the project and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found