You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
no such file or directory COMMIT_EDITMSG on new checkout #589
When checking out a repo, there is no COMMIT_EDITMSG file until a new commit is made. In the case of elastic-apm-node, we trigger the commit lint automatically, as part of the test process. This currently means a fresh checkout can't run the tests because @commitling/cli will crash due to being unable to find that file.
Expected Behavior
There was no commit to have a failing message on, so it should not be a failure.
Current Behavior
It crashes with this output:
/home/stephenbelanger/Code/elastic-apm-node/node_modules/@commitlint/cli/lib/cli.js:113
throw err;
^
Error: ENOENT: no such file or directory, open '/home/stephenbelanger/Code/elastic-apm-node/.git/COMMIT_EDITMSG'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elastic-apm-node@2.5.1 lint-commit: `test/lint-commits.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the elastic-apm-node@2.5.1 lint-commit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/stephenbelanger/.npm/_logs/2019-03-03T19_30_57_446Z-debug.log
Affected packages
cli
core
prompt
config-angular
Possible Solution
Consider it a "pass" if the file is not found.
Steps to Reproduce (for bugs)
Checkout any repo for the first time, which uses @commitlint/cli
Trigger @commitlint/cli
???
😢
Context
Currently this makes the contributing process painful, as new contributors will always run into this the first time they try to run our tests.
Reacted by Krzysztof K, galindroasml, Samuel Denis-D'Ortun, Son Sumin, Italo A., Yohan Dahmani, Prashant Shahi, Piotr Gawron, golegario96 and basevich
No, that's not exactly what we want, because we specifically want to look at if there is a new commit added locally. If there is, we want to lint it. If there is not, we want to skip it.
Regardless of that behavior though, it seems at least confusing that commitlint --edit just throws a missing file error when it's unable to find that file, leaking implementation details, rather than outputting something more useful, if an error is really the behavior you want there. 🤔
Regardless of that behavior though, it seems at least confusing that commitlint --edit just throws a missing file error [...]
You are right, we should add handling for cases where commitlint --edit is called without an edit file being present and communicate clearly what we expect the user to do.
No, that's not exactly what we want, because we specifically want to look at if there is a new commit added locally. If there is, we want to lint it. If there is not, we want to skip it.
Ok - understood. I'd prefer keeping the behaviour of --edit.
I'd consider something like --edit-skip-pristine (very open to name suggestions) which would signal commitlint to back of if the --edit file is not present. Thoughts?
Maybe a separate flag that augments the --edit flag like --edit --skip-empty and then change the default to produce a more useful error when the file is not found?
I faced this problem today, I've created the COMMIT_EDITMSG file on .git folder and my hook backs to work: touch ./.git/COMMIT_EDITMSG
Take a look at file permission, this need to be: -rw-rw-r-- 1 example example 9 jan 31 15:17 COMMIT_EDITMSG
Reacted by escapedcat, Yerkebulan Tulibergenov, Italo A., Andre Hadianto, GuJieYi, visiky, Abhiram Putrevu, Cristian Tangarife, Muhammad Ikhsan, brendaHuang and 11 more
I have the same issue. Disabling commintlint until fixed.
I'm using it with husky
npx --no-install commitlint --edit $1
Also, sometimes it checks the PREVIOUS commit msg and not the one I'm currently trying to commit, resulting in an error if the previous one was in error.
Activity
escapedcat commentedon Mar 4, 2019
Hey @Qard ,
I tried to reproducing your issue by doing:
git clone git@github.com:elastic/apm-agent-nodejs.git(cdin)npm i./node_modules/@commitlint/cli/lib/cli.jsResult:
No error. I don't think this is what you mean. Can you provide more info to be able to recreate your issue? Thanks.
Qard commentedon Mar 8, 2019
Try
npm run lint-commitor justcommitlint --edit.marionebl commentedon Mar 9, 2019
The issue here is the unconditional usage of the
--editflag.An excerpt from
commitlint --helpreveals the flag triggers commitlint to read from fs instead of stdin or the commit history:Based on the comment in your linting script you want to call commitlint like this:
Let me know if this works for you.
Qard commentedon Mar 14, 2019
No, that's not exactly what we want, because we specifically want to look at if there is a new commit added locally. If there is, we want to lint it. If there is not, we want to skip it.
Regardless of that behavior though, it seems at least confusing that
commitlint --editjust throws a missing file error when it's unable to find that file, leaking implementation details, rather than outputting something more useful, if an error is really the behavior you want there. 🤔marionebl commentedon May 31, 2019
You are right, we should add handling for cases where
commitlint --editis called without an edit file being present and communicate clearly what we expect the user to do.Ok - understood. I'd prefer keeping the behaviour of
--edit.I'd consider something like
--edit-skip-pristine(very open to name suggestions) which would signal commitlint to back of if the--editfile is not present. Thoughts?Qard commentedon Jun 3, 2019
Maybe a separate flag that augments the
--editflag like--edit --skip-emptyand then change the default to produce a more useful error when the file is not found?escapedcat commentedon May 12, 2021
If this is still an issue we're happy for PR
gplusdotgr commentedon Nov 29, 2021
I checked out a new branch, and got this same error message.
iaurg commentedon Jan 3, 2022
I faced this problem today, I've created the COMMIT_EDITMSG file on .git folder and my hook backs to work:
touch ./.git/COMMIT_EDITMSGTake a look at file permission, this need to be:
-rw-rw-r-- 1 example example 9 jan 31 15:17 COMMIT_EDITMSGYohandah commentedon Jan 17, 2022
I have the same issue. Disabling commintlint until fixed.
I'm using it with husky
npx --no-install commitlint --edit $1Also, sometimes it checks the PREVIOUS commit msg and not the one I'm currently trying to commit, resulting in an error if the previous one was in error.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010605439/comments/4406713360018
8 remaining items
SampsonM commentedon May 30, 2023
For some reason, the commitlint script isn't looking in the correct place for the git message when I run the husky command.
A fix for me was using the PWD command to tell commitlint where the git message needs linting.
majidzeno commentedon Sep 9, 2024
fix(Jenkinsfile): Touch COMMIT_EDITMSG before pre-commit
fix(Jenkinsfile): Touch COMMIT_EDITMSG before pre-commit
fix(Jenkinsfile): Touch COMMIT_EDITMSG before pre-commit
fix(Jenkinsfile): Touch COMMIT_EDITMSG before pre-commit
fix(Jenkinsfile): Touch COMMIT_EDITMSG before pre-commit
fix(Jenkinsfile): Touch COMMIT_EDITMSG before pre-commit
fix(Jenkinsfile): Touch COMMIT_EDITMSG before pre-commit
fix: preserve cause and tailor message for explicit --edit path (#589)
fix: emit actionable error when --edit cannot find COMMIT_EDITMSG (#589…
gplusdotgr commentedon May 14, 2026
It was fixed BEFORE I go into retirement :-D
j/k , thanks for addressing!
escapedcat commentedon May 14, 2026
Well it's not yet released, so hold your horses
chore(deps): update cr.codefloe.com/docker.io/commitlint/commitlint d…