Skip to content

fix: Segmentation fault: 11 using commitlint@17.4.0 while using Husky commit-msg hook #3485

@doughlass

Description

@doughlass

Expected Behavior

I should be able to commit and Husky runs the commit-msg hook and lints the commit message.

Current Behavior

Unable to proceed to commit due to the following error:

.husky/commit-msg: line 4: 88256 Segmentation fault: 11  npx commitlint --edit ${1}
husky - commit-msg hook exited with code 139 (error)

My commit-msg file is as follows:

#!/bin/sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit ${1}

This is only in the past day I started to receive this error.

If I alter npx commitlint --edit ${1} to be npx commitlint@17.3.0 --edit ${1} I am asked by npx to install 17.3.0 and once installed the commitlint works as expected.

It seems to be since 17.4.0 was released.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

If I change commit-msg to replace the npx command to node node_modules/@commitlint/cli/lib/cli.js --edit $1 I am able to run the commitlint against my message as my local is 17.4.0, it works as expected. Possibly an issue with npx?

Steps to Reproduce

1. Install Husky and Commitlint
2. Run `npx husky add .husky/commit-msg  'npx --no -- commitlint --edit ${1}'`
3. Edit a file, `git add .` and then try to commit a message. eg: `git commit -m "ugly. non-c
onventional commit message"`

Context

Unable to commit using commitlint

commitlint --version

@commitlint/cli@17.4.0

git --version

2.39.0

node --version

v18.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions