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.

pre-commit errors on libsonnet, tf and tfvars files.

See original GitHub issue

describe your issue

Setting types for local binaries fails with:

An error has occurred: InvalidConfigError: 
==> File .pre-commit-config.yaml
==> At Config()
==> At key: repos
==> At Repository(repo='local')
==> At key: hooks
==> At Hook(id='tk')
==> At key: types_or
==> At index 0
=====> Type tag 'libsonnet' is not recognized.  Try upgrading identify and pre-commit?

tk is the tanka binary (which, among other things, formats jsonnet and libsonnet files).

Note that I’m using the zipapp. Which btw doesn’t seem to support --version:

❯ pre-commit --version
shellcheck...........................................(no files to check)Skipped
shfmt................................................(no files to check)Skipped

pre-commit --version

2.18.0

.pre-commit-config.yaml

repos:
  - repo: local
    hooks:

      - id: shellcheck
        name: shellcheck
        entry: shellcheck --external-source --shell=bash
        language: system
        types_or: [sh, shell, bash]

      - id: shfmt
        name: shfmt
        entry: shfmt -bn -ci -sr -i 2
        language: system
        types_or: [sh, shell, bash]

      - id: tk
        name: tk
        entry: tk fmt --test
        language: system
        types_or: [libsonnet, jsonnet]

      - id: terraform
        name: terraform
        entry: terraform fmt -check -diff
        verbose: true
        language: system
        types_or: [tf, tfvars]

~/.cache/pre-commit/pre-commit.log (if present)

version information

pre-commit version: 2.18.0
git --version: git version 2.32.0 (Apple Git-132)
sys.version:
    3.9.12 (main, Mar 26 2022, 15:44:31) 
    [Clang 13.1.6 (clang-1316.0.21.2)]
sys.executable: /Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/python
os.name: posix
sys.platform: darwin

error information

An error has occurred: InvalidConfigError: 
==> File .pre-commit-config.yaml
==> At Config()
==> At key: repos
==> At Repository(repo='local')
==> At key: hooks
==> At Hook(id='tk')
==> At key: types_or
==> At index 0
=====> Type tag 'libsonnet' is not recognized.  Try upgrading identify and pre-commit?
Traceback (most recent call last):
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/pre_commit-2.18.0-py2.py3-none-any.whl/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/pre_commit-2.18.0-py2.py3-none-any.whl/pre_commit/main.py", line 371, in main
    return run(args.config, store, args)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/pre_commit-2.18.0-py2.py3-none-any.whl/pre_commit/commands/run.py", line 398, in run
    config = load_config(config_file)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 411, in load_from_filename
    return apply_defaults(data, schema)
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 43, in reraise_as
    raise tp(e).with_traceback(tb) from None
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 40, in reraise_as
    yield
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 411, in load_from_filename
    return apply_defaults(data, schema)
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 34, in validate_context
    raise ValidationError(e, ctx=msg).with_traceback(tb) from None
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 31, in validate_context
    yield
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 410, in load_from_filename
    validate(data, schema)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 376, in validate
    schema.check(v)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 244, in check
    item.check(v)
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 34, in validate_context
    raise ValidationError(e, ctx=msg).with_traceback(tb) from None
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 31, in validate_context
    yield
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 244, in check
    item.check(v)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 73, in _check_required
    _check_optional(self, dct)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 54, in _check_optional
    self.check_fn(dct[self.key])
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 34, in validate_context
    raise ValidationError(e, ctx=msg).with_traceback(tb) from None
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 31, in validate_context
    yield
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 54, in _check_optional
    self.check_fn(dct[self.key])
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 79, in check_fn
    validate(val, self.schema)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 376, in validate
    schema.check(v)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 272, in check
    validate(val, self.of)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 376, in validate
    schema.check(v)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 244, in check
    item.check(v)
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 34, in validate_context
    raise ValidationError(e, ctx=msg).with_traceback(tb) from None
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 31, in validate_context
    yield
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 244, in check
    item.check(v)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 106, in _check_conditional
    inner(self, dct)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 73, in _check_required
    _check_optional(self, dct)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 54, in _check_optional
    self.check_fn(dct[self.key])
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 34, in validate_context
    raise ValidationError(e, ctx=msg).with_traceback(tb) from None
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 31, in validate_context
    yield
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 54, in _check_optional
    self.check_fn(dct[self.key])
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 79, in check_fn
    validate(val, self.schema)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 376, in validate
    schema.check(v)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 272, in check
    validate(val, self.of)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 376, in validate
    schema.check(v)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 244, in check
    item.check(v)
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 34, in validate_context
    raise ValidationError(e, ctx=msg).with_traceback(tb) from None
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 31, in validate_context
    yield
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 244, in check
    item.check(v)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 54, in _check_optional
    self.check_fn(dct[self.key])
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 34, in validate_context
    raise ValidationError(e, ctx=msg).with_traceback(tb) from None
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 31, in validate_context
    yield
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 54, in _check_optional
    self.check_fn(dct[self.key])
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 364, in check_array_fn
    inner_check(val)
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 34, in validate_context
    raise ValidationError(e, ctx=msg).with_traceback(tb) from None
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 31, in validate_context
    yield
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/cfgv-3.3.1-py2.py3-none-any.whl/cfgv.py", line 364, in check_array_fn
    inner_check(val)
  File "/Users/jimbrannlund/.cache/pre-commit-zipapp/QQilD7wlVmDjE2J87CkXuEuSppeB5fQ4PNiEC4yV9IY/wheels/pre_commit-2.18.0-py2.py3-none-any.whl/pre_commit/clientlib.py", line 30, in check_type_tag
    raise cfgv.ValidationError(
pre_commit.clientlib.InvalidConfigError: 
==> File .pre-commit-config.yaml
==> At Config()
==> At key: repos
==> At Repository(repo='local')
==> At key: hooks
==> At Hook(id='tk')
==> At key: types_or
==> At index 0
=====> Type tag 'libsonnet' is not recognized.  Try upgrading identify and pre-commit?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
asottilecommented, May 4, 2022

ah yeah, the version of identify ships with the zipapp

I just realized I didn’t upload one for 2.18.1 so I can do that now which will have a newer identify version

1reaction
asottilecommented, May 4, 2022

identify maps (among other things) file extensions to named tags – there’s no tf tag, that extension is mapped to the terraform name. in the same way there’s no py tag, it’s “python”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pre-Commit Hooks for Terraform - Medium
Running the Pre-Commit Hook​​ We can see that terraform fmt fixed a syntax issue relating to Terraform code that was within the main.tf...
Read more >
Troubleshooting tfvars error – HashiCorp Help Center
The error could be related to the use, or misconfiguration, of a working directory within the Terraform Enterprise settings.
Read more >
Associations - Material Theme UI Documentation
Name Pattern Examples Github CODE ^CODE_OF_CONDUCT\.(md\|txt)$ CODE_OF_CON... Github CONTRIBUTING ^CONTRIBUTING\.(md\|txt)$ CONTRIBUTING... Github COMMIT ^COMMIT_MESSAGE_CONVENTION\.(md\|txt)$ COMMIT_MESS...
Read more >
Pre-commit override arguments in yaml file - Stack Overflow
Ex: They only need 1 tfvars in dev. I will get the error with pre-commit. So I want to input args as variable...
Read more >
File Extensions in Main Code (267) - cloudfront.net
File Extensions in Main Code (267) ... 13 17 13 lex (1) styl (1) inl (1) glsl (3) php (12) policy (1) tf...
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