Open dimisjim opened 3 years ago
I have exactly same issue
I have found solution to this. Running on self runner you must check availability of node binary in:
/usr/local/bin/node
in my Ubuntu case following helped:
apt update
apt install nodejs
ln -s /usr/bin/nodejs /usr/local/bin/node
@daroga0002 i did the above you suggested, but then i get the error at Terraform init:
failed 4 minutes ago in 7s
Run hashicorp/setup-terraform@v1
with:
cli_config_credentials_hostname: app.terraform.io
terraform_version: latest
terraform_wrapper: true
env:
ARM_CLIENT_ID: ***
ARM_CLIENT_SECRET: ***
ARM_SUBSCRIPTION_ID: ***
ARM_TENANT_ID: ***
TF_VAR_location: westeurope
TF_VAR_resource_name: ***-devops-dev
TF_VAR_sql_user: ***
TF_VAR_sql_password: ***
/usr/bin/unzip -q /home/github-runner-elsa/actions-runner/_work/_temp/fe1b5c37-f386-4451-a746-9fcd852091b0
0s
**Run terraform -chdir=./src/infra init**
terraform -chdir=./src/infra init
shell: /bin/bash -e {0}
env:
ARM_CLIENT_ID: ***
ARM_CLIENT_SECRET: ***
ARM_SUBSCRIPTION_ID: ***
ARM_TENANT_ID: ***
TF_VAR_location: westeurope
TF_VAR_resource_name: ***-devops-dev
TF_VAR_sql_user: ***
TF_VAR_sql_password: ***
TERRAFORM_CLI_PATH: /home/github-runner-elsa/actions-runner/_work/_temp/xxxxxx-d062dfaaf7b7
/home/github-runner-elsa/actions-runner/_work/_temp/xxxxx-062dfaaf7b7/terraform:75
**function cp(source, dest, options = {}) {**
^
**SyntaxError: Unexpected token =**
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
Error: Process completed with exit code 1.
as per me one of your variables seems having some special character what is causing that it escape from variable and breaking action nodejs code
@daroga0002 that was indeed the problem in the end! The variable had a special character, which i have now removed and the pipeline works fine!
I experienced this same issue and resolved the issue by adding the following into my workflow:
steps:
# https://github.com/actions/setup-node
- uses: actions/setup-node@v2
with:
node-version: '14'
Possibly related issue: https://github.com/actions/setup-node/issues/224
We have exactly same issue
I did run just run into the same issue. As mentioned in the README.md: NodeJS must be previously installed with the version specified in the [action.yml](https://github.com/hashicorp/setup-terraform/blob/main/action.yml).
. This is caused by the fact, that terraform
is not the binary but a NodeJS wrapper.
You can install NodeJS in your runner environment, or you can run the setup-node action. But actually, NodeJS is already installed. The setup-terraform
action runs on node20
provided by the runner as an external.
To utilize this runner external, you need to determine its path. For the https://ghcr.io/actions/actions-runner image it is /home/runner/externals/node20/bin/
. Then export and extend the PATH variable in the step where you run terraform:
export PATH="${PATH}:/home/runner/externals/node20/bin/"
This could actually by an idea for the terraform wrapper here. If you somehow manage to get the path of the node external, you could automatically utilize this NodeJS installation.
@dimisjim Hi, folks. I experienced this same issue and resolved the issue by pre-installing node.js in self-hosted actions-runner pod.
The setup-terraform step runs successfully, but the workflow fails during the terraform init process with the following error message:
/usr/bin/env: 'node': No such file or directory
For running setup-terraform on self-hosted GitHub Actions runners, it is necessary to have NodeJS installed. This is mentioned in the official setup-terraform documentation:
When running on self-hosted GitHub Actions runners, NodeJS must be previously installed with the version specified in the action.yml.
Make sure to install NodeJS with the version specified in the action.yml to ensure proper execution.
I resolved the issue by referring to this comment.
The actions-runner executing the setup-terraform
action needs to have the node
command installed to use terraform commands correctly. For Terraform CLI v1.2.0, include a step to install Node.js version 20 using the setup-node
action.
Here is my working setup-terraform code:
jobs:
terraform:
steps:
- name: Checkout code
uses: actions/checkout@v3
# When running on self-hosted GitHub Actions runners,
# NodeJS must be previously installed with the version specified in the action.yml.
- uses: actions/setup-node@v2
with:
node-version: '20'
- name: Setup terraform
uses: actions/setup-terraform@v3
with:
terraform_version: '1.2.0'
- name: Configure AWS Credentials
uses: actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'ap-northeast-2'
- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true
- name: Terraform init
id: init
run: terraform init
Hey there,
I tried using setup-terraform with terraform_wrapper se to true, but getting
I am running this in a self-hosted, dockerized runner. I have tried installing node in the container before running the action but it still fails. I have also tried to install node from within the workflow yaml, but still getting the same.
I have resorted to disable the terraform_wrapper, which then makes the whole workflow run fine.
Could you look into it?