Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/usr/bin/env: 'node' no such file or directory when terraform_wrapper is set to true #84

Open
dimisjim opened this issue Dec 29, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@dimisjim
Copy link

dimisjim commented Dec 29, 2020

Hey there,

I tried using setup-terraform with terraform_wrapper se to true, but getting

image

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?

@daroga0002
Copy link

I have exactly same issue

@daroga0002
Copy link

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

@buttsp
Copy link

buttsp commented Mar 5, 2021

@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.


@daroga0002
Copy link

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

@buttsp
Copy link

buttsp commented Mar 5, 2021

@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!

@jwenz723
Copy link

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'

@aeschright aeschright added the bug Something isn't working label Apr 20, 2021
@jimrazmus
Copy link

Possibly related issue: actions/setup-node#224

@sr-apotapov
Copy link

sr-apotapov commented Jan 26, 2022

We have exactly same issue

@luka5
Copy link

luka5 commented Dec 12, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants