How to fix ERRO Unable to determine underlying exit code in Terraform

TerraformINTERMEDIATEHIGHUpdated Dec 31, 2025Β· 123 views

Terragrunt shows this error when it cannot determine the specific exit code from an underlying command failure. The actual error is usually displayed before this message, making it crucial to look at the full error output to identify the root cause.

Quick fix

Fixes ERRO Unable to determine underlying exit code

terragrunt plan
# Look at ALL output, not just the last line
  1. Look at the full error output before the exit code message
  2. Check for deprecated Terragrunt command syntax
  3. Validate your terragrunt.hcl configuration
  4. Enable debug logging for detailed output
terraform β€” error
terragrunt plan
# Look at ALL output, not just the last line
ERRO Unable to determine underlying exit code

What this error means

The "Unable to determine underlying exit code" error is a catch-all message that Terragrunt displays when an underlying command (typically Terraform) fails in a way that Terragrunt cannot translate to a specific exit code. This is not the actual error itselfβ€”it's Terragrunt's way of saying "something went wrong, but I couldn't figure out exactly what." The real problem is always indicated by the error message that appears immediately before this line. This could be a configuration error, a binary compatibility issue, a missing file, deprecated command syntax, or various other problems. Understanding this pattern is key to troubleshooting: always look up, not at the final error message.

Typical symptoms

  • Terragrunt commands fail with ERRO prefix followed by 'Unable to determine underlying exit code'
  • Exit code is set to 1 but the specific failure reason is unclear
  • Error messages appear above the 'Unable to determine underlying exit code' line but seem incomplete
  • Different commands (plan, apply, init) all fail with this generic error
  • CI/CD pipelines abort due to exit code determination failure

Common causes

  1. Deprecated CLI commands like 'run-all plan' instead of the new 'run --all plan' syntax
  2. Configuration errors in terragrunt.hcl such as missing required fields, duplicate blocks, or syntax errors
  3. Binary architecture mismatches when running in containers (e.g., ARM binary on x86_64 system)
  4. Missing files or missing terragrunt.hcl in the command execution directory
  5. Environment variable issues like AWS_CSM_ENABLED=true causing JSON parsing errors
  6. Git repository or module download failures with incorrect URLs or missing credentials

How to fix "ERRO Unable to determine underlying exit code"

1Look at the full error output before the exit code message

The key to solving this error is examining the error message that appears before the "Unable to determine underlying exit code" line. Copy the entire error output and focus on understanding the first error message shown.

Run your Terragrunt command and carefully read what comes before the exit code error:

bash
terragrunt plan
# Look at ALL output, not just the last line

Common preceding error messages include:
- "The run-all plan command is no longer supported"
- "Only one terraform block is allowed"
- "fork/exec /usr/local/bin/terraform: exec format error"
- "Error reading file at path"
- "Could not parse output from terragrunt config"

2Check for deprecated Terragrunt command syntax

Terragrunt changed its CLI syntax. Update any deprecated run-all commands to the new run --all format.

Old (deprecated):

bash
terragrunt run-all plan
terragrunt run-all apply

New (correct):

bash
terragrunt run --all plan
terragrunt run --all apply

If you're using scripts or CI/CD pipelines, search for 'run-all' and replace with 'run --all'.

3Validate your terragrunt.hcl configuration

Ensure your terragrunt.hcl file has correct syntax and only one terraform block. Run:

bash
terragrunt validate

Check for:
- Duplicate terraform blocks (only one allowed)
- Missing required fields in remote_state configuration (e.g., project for GCS)
- Syntax errors or typos in configuration blocks
- Improperly nested blocks

Fix any configuration issues and try again.

4Enable debug logging for detailed output

Get more information about what Terragrunt is doing by running with debug logging enabled:

bash
terragrunt --terragrunt-log-level debug plan

This will show detailed logs that reveal exactly where the failure occurs. Save the output to a file for easier review:

bash
terragrunt --terragrunt-log-level debug plan 2>&1 | tee debug.log

Look for the first error or warning in the debug output to understand the root cause.

5Verify binary compatibility and environment variables

If you're running in a container or unusual environment, ensure:

1. Terraform and Terragrunt binaries match your system architecture:

bash
file /usr/local/bin/terraform
# Should show: ELF 64-bit LSB executable, x86-64 (or matching your arch)

2. Check for problematic environment variables:

bash
export AWS_CSM_ENABLED=false  # Disable AWS client-side monitoring
terragrunt plan

3. Verify your PATH includes the correct binary locations:

bash
which terraform
which terragrunt
6Check for missing files and module dependencies

Ensure you're running commands from a directory containing terragrunt.hcl and that all referenced modules are accessible:

bash
# Verify terragrunt.hcl exists in current directory
ls -la terragrunt.hcl

# If not, navigate to the correct directory or create a root terragrunt.hcl
cd /path/to/terragrunt/modules

# Try running from the directory with terragrunt.hcl
terragrunt plan

If modules are downloaded from Git, verify:
- Git credentials are configured correctly
- URLs are formatted properly (e.g., 'github.com/org/repo.git//')
- Network connectivity to Git repositories exists

Advanced notes

When Terragrunt wraps Terraform execution, it uses exit codes to determine success or failure. However, in certain edge cases (particularly when dealing with unusual system configurations, container environments, or specific error conditions), Terragrunt cannot parse the underlying process exit code. Rather than guess, it reports this uncertainty with the "Unable to determine underlying exit code" message.

For debugging in CI/CD environments like GitHub Actions, always capture the full stdout and stderr output. The actual error is almost always present in the lines immediately before this message. Tools like Terragrunt error handling blocks and the errors configuration can help manage failures gracefully without relying on exit code determination.

If you consistently encounter this error in a Docker container, ensure you're using multi-stage builds or images with the correct architecture binaries. Using alpine:latest without proper multi-arch setup is a common culprit.

Frequently asked questions

What does "ERRO Unable to determine underlying exit code" mean?
The "Unable to determine underlying exit code" error is a catch-all message that Terragrunt displays when an underlying command (typically Terraform) fails in a way that Terragrunt cannot translate to a specific exit code. " The real problem is always indicated by the error message that appears immediately before this line. This could be a configuration error, a binary compatibility issue, a missing file, deprecated command syntax, or various other problems.
How do I fix "ERRO Unable to determine underlying exit code"?
Terragrunt shows this error when it cannot determine the specific exit code from an underlying command failure. The actual error is usually displayed before this message, making it crucial to look at the full error output to identify the root cause.
What causes "ERRO Unable to determine underlying exit code"?
Deprecated CLI commands like 'run-all plan' instead of the new 'run --all plan' syntax Configuration errors in terragrunt.hcl such as missing required fields, duplicate blocks, or syntax errors Binary architecture mismatches when running in containers (e.g., ARM binary on x86_64 system)
Is the "ERRO Unable to determine underlying exit code" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading