question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improvement(/Bug): Missing shebang causes problems for cli when used with pre-commit

See original GitHub issue

Expected Behavior

pre-commit is a git hook framework which also supports commit-msg hooks. There is a gh-repo which intents to add pre-commit support to commitlint.

After adding this to .pre-commit-config.yaml:

repos:
  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
    rev: a330c424e7903ebbe62b57154456d80d5fbc2b11  # frozen: v4.0.0
    hooks:
      - id: commitlint
        stages: [commit-msg]
        additional_dependencies: ['@commitlint/config-angular']

and installing the hook

$ pre-commit install -t commit-msg

it should run on every commit and abort the commit if commitlint does not give its ok.

Current Behavior

Currently I get an error:

$ git commit -m "test commit"
commitlint...............................................................Failed
- hook id: commitlint
- exit code: 1

[Errno 8] Exec format error: '/home/krys/.cache/pre-commit/repowovky9t0/node_env-system/bin/commitlint'

*** Exit Code: 1 ***

After some googlin’ I found out that a missing shebang could be the cause. And indeed the mentioned file does not have one, starting with:

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
...

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

The aforementioned repo also supports commitlint-travis as a hook. After looking into the commitlint-travis file in the bin directory mentioned in the error I found a shebang: #!/usr/bin/env node. As I don’t have any knowledge on node or JS/TS I could not backtrack those files into the source code as the files seem to differ from the installed ones.

Would it be possible to add a shebang to the corresponding file for commitlint-cli as it is for commitlint-travis?

Steps to Reproduce (for bugs)

  1. You need to have python installed
  2. Install pre-commit: curl https://pre-commit.com/install-local.py | python -
  3. create a git repo
  4. create a .pre-commit-config.yaml file with the content from above
  5. install hook locally pre-commiit install -t commit-msg
  6. try to commit: git commit -a -m "test"

Context

Your Environment

Executable Version
commitlint --version 11.0.0
git --version 2.17.1
node --version v14.15.0

OS: linux mint 19.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
alessandrojcmcommented, May 15, 2021

That was it, funny how that flew under the radar this long. Thanks a lot @AdeAttwood

2reactions
escapedcatcommented, Nov 3, 2020

@ChristianMurphy sorry for tagging you. Tried to tag @Cielquan 😛
@Cielquan and @tkcranny thanks for the info.
We’ll have a look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Supported hooks - pre-commit
cheetah-reorder-imports - This hook reorders imports in cheetah files. cheetah-flake - Lint cheetah code using flake8 and some other checks.
Read more >
git - pre-commit/hook: No such file or directory - Stack Overflow
To fix this, I needed to update the symbolic links in the directory that the shebang ( #! ) line in the .git/hooks/pre-commit...
Read more >
ShellCheck - A shell script static analysis tool - Google Git
ShellCheck - A shell script static analysis tool · To point out and clarify typical beginner's syntax issues that cause a shell to...
Read more >
Changelog - PDM
Fix a bug of missing subdirectory fragment when importing from a requirements.txt . #1036; Fix use_cache.json with corrupted python causes pdm use error....
Read more >
Prepare Commit Message using Git Hook - Mincong Huang
You might need to change the Shebang in your script. Change the interpreter from the Bourne Shell ( #!/bin/sh ) to the Bourne...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found