tfutils / tfenv

Terraform version manager
MIT License
4.41k stars 445 forks source link

bug using tfenv with cdktf #348

Open stephengroat opened 1 year ago

stephengroat commented 1 year ago

have a strange bug where tfenv fails from within cdktf, but does not fail when TFENV_DEBUG=3 is set

not sure how to debug or determine what's wrong

$ cdktf synth
######################################################################## 100.0%
######################################################################## 100.0%
######################################################################## 100.0%
######################################################################## 100.0%
[2022-07-16T18:38:04.540] [ERROR] default - /usr/src/app/.tfenv/lib/tfenv-exec.sh: line 43: /usr/src/app/.tfenv/versions/1.2.4/terraform: Permission denied
/usr/src/app/.tfenv/lib/tfenv-exec.sh: line 43: exec: /usr/src/app/.tfenv/versions/1.2.4/terraform: cannot execute: Permission denied
Terraform CLI not present - Please install a current version https://learn.hashicorp.com/terraform/getting-started/install.html

seems to work if the binary is installed before, i.e. running terraform version before the cdktf command seems to fix it

SandipGorde-TomTom commented 1 year ago

Hi @stephengroat , Even I am also getting similar error. Can you share how can we fix the issue ?

/home/vsts_azpcontainer/.tfenv/lib/tfenv-exec.sh: line 43: /home/vsts_azpcontainer/.tfenv/versions/1.2.4/terraform: Permission denied
/home/vsts_azpcontainer/.tfenv/lib/tfenv-exec.sh: line 43: exec: /home/vsts_azpcontainer/.tfenv/versions/1.2.4/terraform: cannot execute: Permission denied
davidjeddy commented 1 year ago

Getting the same error here. Triggering tfenv in a Jenkins pipeline in parallel steps. From a quick view it looks like two processes are trying to execute tfenv-exec.sh at the same time. In the case of CDK, @SandipGorde-TomTom and @stephengroat can you validate if your processes are also running in parallel?

jamesdehart commented 6 months ago

Check out https://github.com/tfutils/tfenv/issues/398#issue-1734959458 This helped me resolve my issue.

djakielski commented 4 months ago

Hey @jamesdehart could you share how you solved this with cdktf?

davidjeddy commented 2 months ago

@jamesdehart djakielski, @jamesdehart details in #398 tfenv should be invoked with require_serial: true configuration during the first invokation. This will prevent the error from being thrown.