conventional-changelog / commitlint

πŸ““ Lint commit messages
https://commitlint.js.org
MIT License
16.77k stars 902 forks source link

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

Open doughlass opened 1 year ago

doughlass commented 1 year ago

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

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

escapedcat commented 1 year ago

Ugh, thanks.
Need to check but I think commitlint went from husky v8.0.1 to v8.0.3. Will try to find time and see if there's an issue.
If this is a general issue more people will roll in soon I guess. Lets' see.

doughlass commented 1 year ago

Ugh, thanks. Need to check but I think commitlint went from husky v8.0.1 to v8.0.3. Will try to find time and see if there's an issue. If this is a general issue more people will roll in soon I guess. Lets' see.

Sorry for raising it πŸ˜‚

The workaround I have to change the file to read node node_modules/@commitlint/cli/lib/cli.js --edit $1 seems to work.

Hoping that you and the other collaborators can have an official solution for the npx command soon

Shereef commented 1 year ago

I added a duplicate issue #3518 but closed it

here are the details:

Expected Behavior

$ npx commitlint --edit

β§—   input: dfds
βœ–   subject may not be empty [subject-empty]
βœ–   type may not be empty [type-empty]
βœ–   Jira issue reference must be in the subject [jira-issue-reference-in-subject]

βœ–   found 3 problems, 0 warnings
β“˜   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

Current Behavior

> nestjs-bff-mobile-grooming@0.0.0-development lint
> eslint "{src,apps,libs,test}/**/*.ts" --fix && npm run prettier:check

> nestjs-bff-mobile-grooming@0.0.0-development prettier:check
> prettier --check . --ignore-path .gitignore --ignore-unknown

Checking formatting...
All matched files use Prettier code style!
.husky/commit-msg: line 4: 76524 Segmentation fault: 11  npx commitlint --edit
husky - commit-msg hook exited with code 139 (error)

Affected packages

Possible Solution

No response

Steps to Reproduce

https://github.com/conventional-changelog/commitlint#getting-started

Context

npx commitlint --edit



### commitlint --version

@commitlint/cli@17.4.2

### git --version

git version 2.33.0

### node --version

v18.13.0

Thanks!
AnilBairi commented 1 year ago

Same problem. I tried using husky both v8.0.0 and v8.0.3 but no success. I tried to set up this with using yarn I have two commands in pre-commit file. 1) npx pretty-quick --staged β†’ this works fine, see logs below and other commands too like npm -v, echo 2) npx eslint . β†’ this does not work (but works without husky)

logs

πŸ”  Finding changed files since git revision f78a10a.
🎯  Found 0 changed files.
βœ…  Everything is awesome!
.husky/pre-commit: line 5: 53058 Segmentation fault: 11  npx eslint .
husky - pre-commit hook exited with code 139 (error)
Completed with errors, see above

.husky/pre-commit

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

npx pretty-quick --staged
npx eslint .

I am using MacBook Pro with Chip: Apple M1 Max

fothdr commented 1 year ago

try using a different version of node, for example 16.19.0, it helped me

escapedcat commented 12 months ago

According to latest comment this can be fixed by using a newer node version

Shereef commented 12 months ago

I was using 18.13.0 as stated above The original poster was using 18 too

escapedcat commented 12 months ago

I was using 18.13.0 as stated above The original poster was using 18 too

Ah thanks, sorry

ozavraham commented 7 months ago

Had this issue for a while now until I stumbled with this issue and read through the comments, can confirm upgrading the node version to 20.11.1 solved this for me.