title: Terraform external provider - jq in bash script is giving jq: command not found
body: <p>I am on Windows 10 machine, and <a href="https://stedolan.github.io/jq/" rel="nofollow noreferrer">jq</a> is installed using <a href="https://community.chocolatey.org/packages/jq" rel="nofollow noreferrer">choco</a>.</p>
  <p><a href="https://i.stack.imgur.com/9rG8l.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9rG8l.jpg" alt="jq installed" /></a></p>
  <p>I have a simple terraform configuration to understand external provider. And the external provider in this case is <em><strong>bash</strong></em>. When I have jq to format the output, I get the following error.</p>
  <pre><code>data.external.simple-jq-test: Reading...
  ╷
  │ Error: External Program Execution Failed
  │
  │   with data.external.simple-jq-test,
  │   on main.tf line 8, in data &quot;external&quot; &quot;simple-jq-test&quot;:
  │    8:   program = [&quot;bash&quot;, &quot;./simple.sh&quot;]
  │
  │ The data source received an unexpected error while attempting to execute the program.
  │
  │ Program: C:\Windows\system32\bash.exe
  │ Error Message: ./simple.sh: line 4: jq: command not found
  │
  │ State: exit status 127
  ╵
  
  </code></pre>
  <p>You can take a look at the full <a href="https://github.com/AvtsVivek/AzureWithTerraform/tree/main/iac/3401100-external-provider-bash-simple-exmpl" rel="nofollow noreferrer">set of files here on github repo</a>.</p>
  <p>Terraform configuration is as follows.</p>
  <pre><code>
  provider &quot;azurerm&quot; {
    features {}
  }
  
  data &quot;external&quot; &quot;simple-jq-test&quot; {
  
    program = [&quot;bash&quot;, &quot;./simple.sh&quot;]
  
  }
  
  </code></pre>
  <p>And my simple.sh file is as follows.</p>
  <pre><code>#!/bin/bash
  
  function produce_output() {
    jq -n --arg arg1 &quot;arg 1&quot; '{&quot;arg1&quot;:$arg1}'
  }
  
  produce_output
  </code></pre>
  <p>Why is it saying command not found, when jq is properly installed on my machine? Just trying to follow <a href="https://www.cloudwalker.io/2021/10/09/terraform-external-data-source/" rel="nofollow noreferrer">this tutorial.</a></p>
  <p>I was able to successfully create simple examples of Terraform external provider with PowerShell, the examples are <a href="https://github.com/AvtsVivek/AzureWithTerraform/tree/main/iac/3400100-external-provider-ps-simple-example" rel="nofollow noreferrer">here</a> and <a href="https://github.com/AvtsVivek/AzureWithTerraform/tree/main/iac/3400200-external-provider-ps-rg" rel="nofollow noreferrer">here</a> in my repo.</p>
  <p>But when I try with bash and jq inside, I am stuck.</p>
  <h2>Update 14-07-2022</h2>
  <p>When I use powershell, I get the error. But when I switch to bash(git), things are working fine.</p>
  <p>Powershell screen shot.</p>
  <p><a href="https://i.stack.imgur.com/icIlB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/icIlB.png" alt="Terraform plan with Powershell " /></a></p>
  <p>And with git bash</p>
  <p><a href="https://i.stack.imgur.com/JFrn8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JFrn8.png" alt="Terraform plan with git bash" /></a></p>
  <p>Finally things are working.</p>