no such file or directory COMMIT_EDITMSG on new checkout
See original GitHub issueWhen 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.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:16 (2 by maintainers)
Top Results From Across the Web
could not open git/commit_editmsg - Stack Overflow
To solve this, simply navigate to your .git folder and delete the "COMMIT_EDITMSG" file. Share.
Read more >Git - git-commit Documentation
Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are...
Read more >Git error could not open git/commit_editmsg - YouTube
git error fatal: could not open '.git/ COMMIT_EDITMSG ': Permission deniedGit error when commit in windows fatal: could not open ...
Read more >How to Modify the Last Git Commit Message | by Pavol Kutaj
hint: Waiting for your editor to close the file. ... VS Code\Code.exe: No such file or directory ... Learn on the go with...
Read more >Change the default comments in GIT's COMMIT_EDITMSG ...
I don't know if the default message is in the file at the point the hook is run, but even if not, you...
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 FreeTop 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
Top GitHub Comments
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
I’m quite certain this is the result of a miss-configuration and not a fault in the commitlint itself.
This happens if you by mistake add commitlint to
pre-commit
instead ofcommit-msg
hook (I know it by doing)