Skip to content

cz commit -e crashes on editor exit #1352

Closed
@naimmas

Description

@naimmas

Description

I want to add multi-line description so first I initialize my commit message header and then added the description using vim editor, but on write and quite :wq I received the following error

cz commit -e
? Select the type of change you are committing feat: A new feature. Correlates with MINOR in SemVer
? What is the scope of this change? (class or file name): (press [enter] to skip)
 HW timer
? Write a short and imperative summary of the code changes: (lower case and no period)
 feat and fixes
? Provide additional contextual information about the code changes: (press [enter] to skip)
 
? Is this a BREAKING CHANGE? Correlates with MAJOR in SemVer No
? Footer. Information about Breaking Changes and reference issues that this commit closes: (press [enter] to skip)
 
Traceback (most recent call last):
  File "/usr/local/bin/cz", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/local/Cellar/commitizen/4.1.1/libexec/lib/python3.13/site-packages/commitizen/cli.py", line 651, in main
    args.func(conf, arguments)()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/Cellar/commitizen/4.1.1/libexec/lib/python3.13/site-packages/commitizen/commands/commit.py", line 130, in __call__
    m = self.manual_edit(m)
  File "/usr/local/Cellar/commitizen/4.1.1/libexec/lib/python3.13/site-packages/commitizen/commands/commit.py", line 92, in manual_edit
    file.unlink()
    ^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/tempfile.py", line 494, in __getattr__
    a = getattr(file, name)
AttributeError: '_io.TextIOWrapper' object has no attribute 'unlink'

Steps to reproduce

make sure that the vim editor is the default editor in bash

cz commit -e
edit the message
exit insert mode
write & quite :wq

Current behavior

The following error thrown on editor exit and commit message not saved in .git/COMMIT_EDITMSG

Traceback (most recent call last):
  File "/usr/local/bin/cz", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/local/Cellar/commitizen/4.1.1/libexec/lib/python3.13/site-packages/commitizen/cli.py", line 651, in main
    args.func(conf, arguments)()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/Cellar/commitizen/4.1.1/libexec/lib/python3.13/site-packages/commitizen/commands/commit.py", line 130, in __call__
    m = self.manual_edit(m)
  File "/usr/local/Cellar/commitizen/4.1.1/libexec/lib/python3.13/site-packages/commitizen/commands/commit.py", line 92, in manual_edit
    file.unlink()
    ^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/tempfile.py", line 494, in __getattr__
    a = getattr(file, name)
AttributeError: '_io.TextIOWrapper' object has no attribute 'unlink'

Desired behavior

committing the updated message

Screenshots

Image

Environment

OS: macOS Sequoia Version 15.3 (24D60)
Vim version 9.1.754

> cz version --report
Commitizen Version: 4.1.1
Python Version: 3.13.2 (main, Feb  4 2025, 14:51:09) [Clang 16.0.0 (clang-1600.0.26.6)]
Operating System: Darwin 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions