Skip to content

Duplicate local definition or Duplicate variable #57

@esacteksab

Description

@esacteksab

🐛 Summary

Running packer_validate always returns failed. Passing --verbose to pre-commit doesn't show anything further.

Running Packer v1.11.2
Running pre-commit 4.0.1
Running 0.3.0 of pre-commit-packer
Running on x86 MacOS (latest release)

There are 10 Packer files in the root of the directory.

To reproduce

Steps to reproduce the behavior:

Can run PACKER_LOG=1 pre-commit run --all-files and I get an output like this

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

Error: Duplicate local definition

  on host1.pkr.hcl line 25, in locals:
  25:   timestamp = regex_replace(timestamp(), "[- TZ:]", "")

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

Error: Duplicate local definition

  on host3.pkr.hcl line 24, in locals:
  24:   timestamp = regex_replace(timestamp(), "[- TZ:]", "")

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

Error: Duplicate local definition

  on host4.pkr.hcl line 24, in locals:
  24:   timestamp = regex_replace(timestamp(), "[- TZ:]", "")

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

Error: Duplicate local definition

  on host5.pkr.hcl line 24, in locals:
  24:   timestamp = regex_replace(timestamp(), "[- TZ:]", "")

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

Error: Duplicate local definition

  on host6.pkr.hcl line 24, in locals:
  24:   timestamp = regex_replace(timestamp(), "[- TZ:]", "")

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

2025/02/04 15:55:47 [INFO] (telemetry) Finalizing.
2025/02/04 15:55:47 waiting for all plugin processes to complete...

Expected behavior

for file in $(ls |grep pkr.hcl); do packer validate $file; done
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.

Any helpful log output or screenshots

Paste the results here:

See above I believe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions