Run `cz init` will raise `UnicodeDecodeError`
See original GitHub issueDescription
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
- Create a empty directory
- Enter the directory
- 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\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\aa\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\AA\AppData\Local\Programs\Python\Python38\Scripts\cz.exe\__main__.py", line 7, in <module>
File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\cli.py", line 301, in main
args.func(conf, vars(args))()
File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\commands\init.py", line 43, in __call__
self._install_pre_commit_hook()
File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\commands\init.py", line 144, in _install_pre_commit_hook
c = cmd.run("pre-commit install --hook-type commit-msg")
File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\cmd.py", 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.
Environment
- 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:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top 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 webzdarma.cz. 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No problem.
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?