Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows. local hook] Failed to parse CLI arguments; Failed to load service-account.tf: Multiple files in different directories are not allowed #394

Closed
simtcrom opened this issue Jun 2, 2022 · 2 comments
Labels
3rd party Issues not related to `pre-commit-terraform` area/windows question

Comments

@simtcrom
Copy link

simtcrom commented Jun 2, 2022

Describe the bug

.pre-commit-config.yaml

repos:
  - repo: https://github.com/antonbabenko/pre-commit-terraform
    rev: "v1.72.1"
    hooks:
      - id: terraform_fmt
        entry: terraform fmt -recursive
        language: system
        pass_filenames: false
      - id: terraform_docs
        entry: 'terraform-docs markdown .'
        args:
        - --output-file=README.md
        language: system
        pass_filenames: false
      - id: terraform_tflint
        entry: tflint
        language: system

when I do,

PS C:\Users> git commit -m "added terradocs"
Terraform fmt............................................................Passed
Terraform docs...........................................................Passed
Terraform validate with tflint...........................................Failed
- hook id: terraform_tflint
- exit code: 1


Failed to parse CLI arguments; Failed to load `service-account.tf`: Multiple files in different directories are not allowed

I have service-account.tf at the folder where I run commit

Any thoughts?

Environment information

OS: Win10 with Ubuntu 18.04 on WSL2

~$ uname -a
Linux xxxxxxxxxxx 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

PS C:\Users> pre-commit --version
pre-commit 2.19.0

PS C:\Users> terraform --version
Terraform v0.15.5
on windows_amd64

PS C:\Users> python --version
Python 3.8.10

PS C:\Users> terraform-docs --version
terraform-docs version v0.16.0 1f686b1 windows/amd64

PS C:\Users> tflint --version
TFLint version 0.37.0
@MaxymVlasov
Copy link
Collaborator

MaxymVlasov commented Jun 2, 2022

You run it from PowerShell, not Bash.
We do not support PowerShell execution, use git inside WSL.

That's amazing that at least part of stuff works in PS with not very edited .pre-commit-config.yaml
UPD. By redefining entry - you stop use pre-commit-terraform hooks. So no one of the three hooks use pre-commit-terraform - you can switch to local hook and nothing will change

@MaxymVlasov MaxymVlasov added wontfix This will not be worked on bug Something isn't working and removed area/local_installation bug Something isn't working labels Jun 2, 2022
@MaxymVlasov
Copy link
Collaborator

Also, you redefined entry, so you got what you got -> terraform-linters/tflint#1246

- id: terraform_tflint
name: Terraform validate with tflint
description: Validates all Terraform configuration files with TFLint.
require_serial: true
entry: hooks/terraform_tflint.sh
language: script
files: (\.tf|\.tfvars)$
exclude: \.terraform\/.*$

@MaxymVlasov MaxymVlasov added 3rd party Issues not related to `pre-commit-terraform` question and removed bug Something isn't working wontfix This will not be worked on labels Jun 2, 2022
@MaxymVlasov MaxymVlasov changed the title Failed to parse CLI arguments; Failed to load service-account.tf: Multiple files in different directories are not allowed [Windows. local hook] Failed to parse CLI arguments; Failed to load service-account.tf: Multiple files in different directories are not allowed Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party Issues not related to `pre-commit-terraform` area/windows question
Projects
None yet
Development

No branches or pull requests

2 participants