[GH-ISSUE #491] Terraform commands failed with permission denied when using hashicorp-setup-terraform@v1 on Windows #338

Open
opened 2026-03-01 21:42:29 +03:00 by kerem · 12 comments
Owner

Originally created by @cdhunt on GitHub (Jan 20, 2021).
Original GitHub issue: https://github.com/nektos/act/issues/491

The workflow works as expected from WSL, but from the WIndows client, act is unable to execute commands.

There is a little bit of additional context in #437.

Debug output for the hashicorp-setup-terraform step.

[Dev/Terraform]   💬  ::debug::Terraform CLI path is /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926.
[Dev/Terraform]   💬  ::debug::Moving /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926/terraform to /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926/terraform-bin.
[Dev/Terraform]   💬  ::debug::Copying /actions/hashicorp-setup-terraform@v1/dist/index1.js to /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926/terraform.
[Dev/Terraform]   ⚙  ::add-path:: /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926
[Dev/Terraform]   ✅  Success - hashicorp/setup-terraform@v1

Output from Terraform Format step.

[Dev/Terraform] ⭐  Run Terraform Format
time="2021-01-20T13:56:12-05:00" level=debug msg="Wrote command 'terraform fmt -check' to 'workflow/fmt'"
time="2021-01-20T13:56:12-05:00" level=debug msg="Writing entry to tarball workflow/fmt len:20"
[Dev/Terraform] Extracting content to '/github/'
[Dev/Terraform] Exec command '[bash --noprofile --norc -eo pipefail /github/workflow/fmt]'
| /github/workflow/fmt: line 1: /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926/terraform: Permission denied
[Dev/Terraform]   ❌  Failure - Terraform Format
time="2021-01-20T13:56:12-05:00" level=debug msg="exit with `FAILURE`: 126"
> docker version
Client: Docker Engine - Community
 Cloud integration: 1.0.4
 Version:           20.10.2
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        2291f61
 Built:             Mon Dec 28 16:14:16 2020
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true
Originally created by @cdhunt on GitHub (Jan 20, 2021). Original GitHub issue: https://github.com/nektos/act/issues/491 The workflow works as expected from WSL, but from the WIndows client, act is unable to execute commands. There is a little bit of additional context in #437. Debug output for the hashicorp-setup-terraform step. ``` [Dev/Terraform] 💬 ::debug::Terraform CLI path is /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926. [Dev/Terraform] 💬 ::debug::Moving /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926/terraform to /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926/terraform-bin. [Dev/Terraform] 💬 ::debug::Copying /actions/hashicorp-setup-terraform@v1/dist/index1.js to /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926/terraform. [Dev/Terraform] ⚙ ::add-path:: /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926 [Dev/Terraform] ✅ Success - hashicorp/setup-terraform@v1 ``` Output from Terraform Format step. ``` [Dev/Terraform] ⭐ Run Terraform Format time="2021-01-20T13:56:12-05:00" level=debug msg="Wrote command 'terraform fmt -check' to 'workflow/fmt'" time="2021-01-20T13:56:12-05:00" level=debug msg="Writing entry to tarball workflow/fmt len:20" [Dev/Terraform] Extracting content to '/github/' [Dev/Terraform] Exec command '[bash --noprofile --norc -eo pipefail /github/workflow/fmt]' | /github/workflow/fmt: line 1: /tmp/a7dfec18-44fa-4226-ab7e-88a951b1d926/terraform: Permission denied [Dev/Terraform] ❌ Failure - Terraform Format time="2021-01-20T13:56:12-05:00" level=debug msg="exit with `FAILURE`: 126" ``` ```powershell > docker version Client: Docker Engine - Community Cloud integration: 1.0.4 Version: 20.10.2 API version: 1.41 Go version: go1.13.15 Git commit: 2291f61 Built: Mon Dec 28 16:14:16 2020 OS/Arch: windows/amd64 Context: default Experimental: true ```
Author
Owner

@edtan-caseware commented on GitHub (Jan 20, 2021):

One thing I've noticed is that the execution flag is missing from the terraform script when run from Windows:

root@docker-desktop:/github/workspace# ls -l /tmp/49a791f2-9668-415a-9605-0365673d086f/
total 83620
-rw-rw-rw- 1 root root    63187 Jan 20 20:16 terraform
-rwxr-xr-x 1 root root 85561299 Jan  6 19:04 terraform-bin

But in Linux/WSL, the execute bit is set:

root@docker-desktop:/github/workspace# ls -l /tmp/993cb99e-cc79-4bee-a4e7-e611b2ebfa1f/
total 83620
-rwxr-xr-x 1 root root    63187 Jan 20 20:15 terraform
-rwxr-xr-x 1 root root 85561299 Jan  6 19:04 terraform-bin
<!-- gh-comment-id:763907822 --> @edtan-caseware commented on GitHub (Jan 20, 2021): One thing I've noticed is that the execution flag is missing from the `terraform` script when run from Windows: ``` root@docker-desktop:/github/workspace# ls -l /tmp/49a791f2-9668-415a-9605-0365673d086f/ total 83620 -rw-rw-rw- 1 root root 63187 Jan 20 20:16 terraform -rwxr-xr-x 1 root root 85561299 Jan 6 19:04 terraform-bin ``` But in Linux/WSL, the execute bit is set: ``` root@docker-desktop:/github/workspace# ls -l /tmp/993cb99e-cc79-4bee-a4e7-e611b2ebfa1f/ total 83620 -rwxr-xr-x 1 root root 63187 Jan 20 20:15 terraform -rwxr-xr-x 1 root root 85561299 Jan 6 19:04 terraform-bin ```
Author
Owner

@catthehacker commented on GitHub (Jan 20, 2021):

This is because permission system is completely different between Windows and Linux, didn't had time to look at where and how it does but I assume act can recursively chmod +x all actions after copy when runtime.GOOS == 'windows'.

<!-- gh-comment-id:763984481 --> @catthehacker commented on GitHub (Jan 20, 2021): This is because permission system is completely different between Windows and Linux, didn't had time to look at where and how it does but I assume `act` can recursively `chmod +x` all actions after copy when `runtime.GOOS == 'windows'`.
Author
Owner

@cdhunt commented on GitHub (Jan 21, 2021):

I assume that is the case. Despite being a copy from a Linux container to a Linux container, invoking through the Windows client is messing it up.

<!-- gh-comment-id:764679785 --> @cdhunt commented on GitHub (Jan 21, 2021): I assume that is the case. Despite being a copy from a Linux container to a Linux container, invoking through the Windows client is messing it up.
Author
Owner

@catthehacker commented on GitHub (Jan 21, 2021):

@cdhunt It's not Linux<>Linux copy

::debug::Copying /actions/hashicorp-setup-terraform@v1/dist/index1.js to /tmp/3ebc1b30-79a1-4ab6-ae5f-d62eb03aeadc/terraform.

I actually have no idea if that can be solved just in act with Go
image

<!-- gh-comment-id:764696420 --> @catthehacker commented on GitHub (Jan 21, 2021): @cdhunt It's not Linux<>Linux copy ``` ::debug::Copying /actions/hashicorp-setup-terraform@v1/dist/index1.js to /tmp/3ebc1b30-79a1-4ab6-ae5f-d62eb03aeadc/terraform. ``` I actually have no idea if that can be solved just in `act` with Go ![image](https://user-images.githubusercontent.com/31106839/105367154-705f9600-5c00-11eb-88bc-9092d3947aaa.png)
Author
Owner

@cdhunt commented on GitHub (Jan 21, 2021):

Yeah, I looked through the code and see it dumps to the local filesystem before copying into the container.

Can you exec a chmod +x here.

<!-- gh-comment-id:764741668 --> @cdhunt commented on GitHub (Jan 21, 2021): Yeah, I looked through the code and see it dumps to the local filesystem before copying into the container. Can you `exec` a `chmod +x` [here](https://github.com/nektos/act/blob/e6fcfed458dbccd640e093bffd0fc258d6ce0e6e/pkg/container/docker_run.go#L510-L513).
Author
Owner

@github-actions[bot] commented on GitHub (Feb 21, 2021):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:782770786 --> @github-actions[bot] commented on GitHub (Feb 21, 2021): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@cdhunt commented on GitHub (Feb 22, 2021):

This would be incredibly useful functionality to support.

<!-- gh-comment-id:783692211 --> @cdhunt commented on GitHub (Feb 22, 2021): This would be incredibly useful functionality to support.
Author
Owner

@github-actions[bot] commented on GitHub (Mar 25, 2021):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:806270188 --> @github-actions[bot] commented on GitHub (Mar 25, 2021): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@cdhunt commented on GitHub (Mar 26, 2021):

bump

<!-- gh-comment-id:808209171 --> @cdhunt commented on GitHub (Mar 26, 2021): bump
Author
Owner

@dtracers commented on GitHub (Aug 31, 2021):

was this ever solved?

I am also using a windows system and having issues with permission denied errors

<!-- gh-comment-id:908821828 --> @dtracers commented on GitHub (Aug 31, 2021): was this ever solved? I am also using a windows system and having issues with permission denied errors
Author
Owner

@JasonCubic commented on GitHub (Dec 22, 2022):

A workaround is to add this step after you install terraform.

# bug with act and terraform permissions: https://github.com/nektos/act/issues/491
- name: fix terraform file permissions
  run: find /tmp -name "terraform" -type f -exec chmod 755 {} +
<!-- gh-comment-id:1363321159 --> @JasonCubic commented on GitHub (Dec 22, 2022): A workaround is to add this step after you install terraform. ```yaml # bug with act and terraform permissions: https://github.com/nektos/act/issues/491 - name: fix terraform file permissions run: find /tmp -name "terraform" -type f -exec chmod 755 {} + ```
Author
Owner

@ForNeVeR commented on GitHub (Apr 6, 2023):

Theoretically, it could consult Git about the file flags if started from Windows.

Say,

$ git ls-files --stage gradlew
100755 572252646b9962fbf8261861ffa7bc7f403d3386 0       gradlew

This means the file should have the execute bit set.

<!-- gh-comment-id:1499584760 --> @ForNeVeR commented on GitHub (Apr 6, 2023): Theoretically, it could consult Git about the file flags if started from Windows. Say, ```console $ git ls-files --stage gradlew 100755 572252646b9962fbf8261861ffa7bc7f403d3386 0 gradlew ``` This means the file should have the execute bit set.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#338
No description provided.