gruntwork-io / gruntwork-io/pre-commit

"terraform-validate", "terraform-fmt" fails with "command not found" in Linux-based systems due to ^M carriage return character

Open
#65 3 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Shell
Stars
547
Forks
168
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
"pre-commit run terraform-validate --all-files" command fails until I follow [Remove the spurious CR characters steps](https://www.studytonight.com/post/solved-getting-error-while-executing-a-sh-file-binbashm-bad-interpreter) to use sed to remove "The ^M is a carriage return character":
Screen Shot 2021-12-31 at 15 42 29

**To Reproduce**
Steps to reproduce the behavior including the relevant Terraform/Terragrunt/Packer version number and any code snippets and module inputs you used.
1. Install pre-commit in Mac OS or some linux flavor OS (Ubuntu, etc.) & create a `.pre-commit-config.yaml` as defined in [Pre-commit README.md > General Usage](https://github.com/gruntwork-io/pre-commit#general-usage)
2. Run `pre-commit run terraform-validate --all-files`
3. See failures, now run `sed -i -e 's/\r$//' /Users/arriaga/.cache/pre-commit/repo57cjvft5/hooks/terraform-validate.sh`
4. Re-try `pre-commit run terraform-validate --all-files` and see how errors g oaway

**Expected behavior**
Maybe pre-commit hooks should avoid having the "^M" carriage return character?

**Additional context**
Tried to follow "Step 3 - Static Analysis" steps of [Getting Started with Terraform on Azure: Testing](https://cloudskills.io/blog/terraform-azure-08) blog article

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.