tfenv icon indicating copy to clipboard operation
tfenv copied to clipboard

bug using tfenv with cdktf

Open stephengroat opened this issue 2 years ago • 5 comments

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

stephengroat avatar Jul 16 '22 18:07 stephengroat

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

SandipGorde-TomTom avatar May 04 '23 11:05 SandipGorde-TomTom

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?

davidjeddy avatar May 11 '23 08:05 davidjeddy

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

bethdehart avatar Dec 13 '23 16:12 bethdehart

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

djakielski avatar Feb 27 '24 21:02 djakielski

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

davidjeddy avatar Apr 08 '24 07:04 davidjeddy