[GH-ISSUE #228] MODULE_NOT_FOUND during docker cp command #158

Closed
opened 2026-03-01 21:40:43 +03:00 by kerem · 14 comments
Owner

Originally created by @pmatheson-greenphire on GitHub (May 8, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/228

Command I'm running
act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04

Error output

 ☁  git clone 'https://github.com/gittools/actions' # ref=v0.9.2
[]   🐳  docker cp src=/home/user/.cache/act/gittools-actions-gitversion-setup@v0.9.2 dst=/actions/
| internal/modules/cjs/loader.js:985
|   throw err;
|   ^
| 
| Error: Cannot find module '/actions/gittools-actions-gitversion-setup@v0.9.2/dist/github/gitversion/setup/bundle.js'
|     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
|     at Function.Module._load (internal/modules/cjs/loader.js:864:27)
|     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
|     at internal/main/run_main_module.js:18:47 {
|   code: 'MODULE_NOT_FOUND',

it looks like the code from gittools-actions-gitversion-setup@v0.9.2 is copied to /actions/ in the container but the action javascript expects the original directory name to be in the path. So the cp should be cp /home/user/.cache/act/gittools-actions-gitversion-setup@v0.9.2 /actions/gittools-actions-gitversion-setup@v0.9.2

Originally created by @pmatheson-greenphire on GitHub (May 8, 2020). Original GitHub issue: https://github.com/nektos/act/issues/228 Command I'm running `act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 ` Error output ``` ☁ git clone 'https://github.com/gittools/actions' # ref=v0.9.2 [] 🐳 docker cp src=/home/user/.cache/act/gittools-actions-gitversion-setup@v0.9.2 dst=/actions/ | internal/modules/cjs/loader.js:985 | throw err; | ^ | | Error: Cannot find module '/actions/gittools-actions-gitversion-setup@v0.9.2/dist/github/gitversion/setup/bundle.js' | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15) | at Function.Module._load (internal/modules/cjs/loader.js:864:27) | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) | at internal/main/run_main_module.js:18:47 { | code: 'MODULE_NOT_FOUND', ``` it looks like the code from gittools-actions-gitversion-setup@v0.9.2 is copied to /actions/ in the container but the action javascript expects the original directory name to be in the path. So the cp should be `cp /home/user/.cache/act/gittools-actions-gitversion-setup@v0.9.2 /actions/gittools-actions-gitversion-setup@v0.9.2`
Author
Owner

@rdlf0 commented on GitHub (May 10, 2020):

I had some hard time with this, too, but after some digging through the code I found out that in order to get the correct dst path you have to provide the path key in the actions/checkout step like this:

steps:
  - name: Checkout
    uses: actions/checkout@v2
    with:
      path: "your-action-root-directory"

I guess this should be better documented in order to save the others the time I had to spend on looking into it.

<!-- gh-comment-id:626256671 --> @rdlf0 commented on GitHub (May 10, 2020): I had some hard time with this, too, but after some digging through the code I found out that in order to get the correct `dst` path you have to provide the `path` key in the `actions/checkout` step like this: ```yml steps: - name: Checkout uses: actions/checkout@v2 with: path: "your-action-root-directory" ``` I guess this should be better documented in order to save the others the time I had to spend on looking into it.
Author
Owner

@pmatheson-greenphire commented on GitHub (May 11, 2020):

This doesn't seem like it would solve the problem - it just changes the destination directory of the initial checkout from /github/workflow/ to /github/workflow/${PATH}

<!-- gh-comment-id:626664809 --> @pmatheson-greenphire commented on GitHub (May 11, 2020): This doesn't seem like it would solve the problem - it just changes the destination directory of the initial checkout from `/github/workflow/` to `/github/workflow/${PATH}`
Author
Owner

@rdlf0 commented on GitHub (May 11, 2020):

This doesn't seem like it would solve the problem - it just changes the destination directory of the initial checkout from /github/workflow/ to /github/workflow/${PATH}

Yup! And that's how the path provided to cp becomes the one you suggested and the MODULE_NOT_FOUND error is gone. As far as I can understand your issue this seems to be the case. In my situation this was the solution.

<!-- gh-comment-id:626706680 --> @rdlf0 commented on GitHub (May 11, 2020): > This doesn't seem like it would solve the problem - it just changes the destination directory of the initial checkout from `/github/workflow/` to `/github/workflow/${PATH}` Yup! And that's how the path provided to `cp` becomes the one you suggested and the `MODULE_NOT_FOUND` error is gone. As far as I can understand your issue this seems to be the case. In my situation this was the solution.
Author
Owner

@tachuris commented on GitHub (May 16, 2020):

The problem is that docker cp interprets .gitignore (see current version), in particular the rule that should not ignore the *.js files in dist/:

!dist/**/*.js

...as if it were a .dockerignore file, which doesn't support exception (!) rules.

So if you check the contents of the copy destination, there is no *.js:

docker exec <act-job-container-name> ls -R /actions/gittools-actions-gitversion-setup@v0.9.2/dist/

A workaround is removing the problematic .gitignore rules in a fork or just deleting .gitignore (which I think act could do before docker cp, @cplee ).

See my fork here: https://github.com/GitTools/actions/compare/master...rstuven:patch-1
You can try it using the action rstuven/actions/gitversion/setup@patch-1 or replicating the change in a fork of your own.

<!-- gh-comment-id:629709055 --> @tachuris commented on GitHub (May 16, 2020): The problem is that `docker cp` interprets .gitignore ([see current version](https://github.com/GitTools/actions/blob/64f41a665bb0cebd4d14370b8472c747fe8ecd22/.gitignore#L4-L5)), in particular the rule that should not ignore the *.js files in dist/: ``` !dist/**/*.js ``` ...as if it were a .dockerignore file, [which doesn't support exception (`!`) rules](https://docs.docker.com/engine/reference/builder/#dockerignore-file). So if you check the contents of the copy destination, there is no *.js: ``` docker exec <act-job-container-name> ls -R /actions/gittools-actions-gitversion-setup@v0.9.2/dist/ ``` A workaround is removing the problematic .gitignore rules in a fork or just deleting .gitignore (which I think `act` could do before `docker cp`, @cplee ). See my fork here: https://github.com/GitTools/actions/compare/master...rstuven:patch-1 You can try it using the action `rstuven/actions/gitversion/setup@patch-1` or replicating the change in a fork of your own.
Author
Owner

@ColinM9991 commented on GitHub (Jul 11, 2020):

I'm currently having this issue with the same described behaviour when it's working with actions for a .NET Core application.

I am developing on a Windows environment and building on a Linux environment.

[34m[CI Build - Master/build] [0m Run Setup .NET Core
[34m[CI Build - Master/build] [0m ☁ git clone 'https://github.com/actions/setup-dotnet' # ref=v1
[34m[CI Build - Master/build] [0m 🐳 docker cp src=act/actions-setup-dotnet@v1 dst=/actions
[34m|[0m internal/modules/cjs/loader.js:628
[34m|[0m throw err;
[34m|[0m ^
[34m|[0m
[34m|[0m Error: Cannot find module '/github/workspace/\actions\actions-setup-dotnet@v1\dist\index.js'
[34m|[0m [90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)[39m
[34m|[0m [90m at Function.Module._load (internal/modules/cjs/loader.js:527:27)[39m
[34m|[0m [90m at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)[39m
[34m|[0m [90m at internal/main/run_main_module.js:17:11[39m {
[34m|[0m code: [32m'MODULE_NOT_FOUND'[39m,
[34m|[0m requireStack: []
[34m|[0m }
[34m[CI Build - Master/build] [0m Failure - Setup .NET Core
Error: exit with FAILURE: 1

<!-- gh-comment-id:657067980 --> @ColinM9991 commented on GitHub (Jul 11, 2020): I'm currently having this issue with the same described behaviour when it's working with actions for a .NET Core application. I am developing on a Windows environment and building on a Linux environment. >[34m[CI Build - Master/build] [0m⭐ Run Setup .NET Core [34m[CI Build - Master/build] [0m ☁ git clone 'https://github.com/actions/setup-dotnet' # ref=v1 [34m[CI Build - Master/build] [0m 🐳 docker cp src=act/actions-setup-dotnet@v1 dst=/actions\ [34m|[0m internal/modules/cjs/loader.js:628 [34m|[0m throw err; [34m|[0m ^ [34m|[0m [34m|[0m Error: Cannot find module '/github/workspace/\actions\actions-setup-dotnet@v1\dist\index.js' [34m|[0m [90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)[39m [34m|[0m [90m at Function.Module._load (internal/modules/cjs/loader.js:527:27)[39m [34m|[0m [90m at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)[39m [34m|[0m [90m at internal/main/run_main_module.js:17:11[39m { [34m|[0m code: [32m'MODULE_NOT_FOUND'[39m, [34m|[0m requireStack: [] [34m|[0m } [34m[CI Build - Master/build] [0m ❌ Failure - Setup .NET Core Error: exit with `FAILURE`: 1
Author
Owner

@tyler274 commented on GitHub (Aug 2, 2020):

similar issue over here too

[CI/Check ubuntu-latest (stable)-1 ]   🐳  docker cp src=act/actions-rs-toolchain@v1 dst=/actions\
| internal/modules/cjs/loader.js:628
|     throw err;
|     ^
|
| Error: Cannot find module '/github/workspace/\actions\actions-rs-toolchain@v1\dist\index.js'
|     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
|     at Function.Module._load (internal/modules/cjs/loader.js:527:27)
|     at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
|     at internal/main/run_main_module.js:17:11 {
|   code: 'MODULE_NOT_FOUND',
|   requireStack: []
| }
[CI/Check ubuntu-latest (stable)-1 ]     Failure - actions-rs/toolchain@v1
<!-- gh-comment-id:667604607 --> @tyler274 commented on GitHub (Aug 2, 2020): similar issue over here too ```javascript [CI/Check ubuntu-latest (stable)-1 ] 🐳 docker cp src=act/actions-rs-toolchain@v1 dst=/actions\ | internal/modules/cjs/loader.js:628 | throw err; | ^ | | Error: Cannot find module '/github/workspace/\actions\actions-rs-toolchain@v1\dist\index.js' | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15) | at Function.Module._load (internal/modules/cjs/loader.js:527:27) | at Function.Module.runMain (internal/modules/cjs/loader.js:839:10) | at internal/main/run_main_module.js:17:11 { | code: 'MODULE_NOT_FOUND', | requireStack: [] | } [CI/Check ubuntu-latest (stable)-1 ] ❌ Failure - actions-rs/toolchain@v1 ```
Author
Owner

@orihomie commented on GitHub (Dec 11, 2020):

➜  slurpy git:(master) ✗ act -W .github/workflows_test
[Tests CI/tests] 🚀  Start image=node:12.6-buster-slim
[Tests CI/tests]   🐳  docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Tests CI/tests]   🐳  docker cp src=/Users/orkhan.mamedov/PycharmProjects/slurpy/. dst=/github/workspace/~/PycharmProjects/slurpy
[Tests CI/tests] ⭐  Run Checkout
[Tests CI/tests]   ✅  Success - Checkout
[Tests CI/tests] ⭐  Run build
| /github/workflow/1: line 1: docker: command not found
[Tests CI/tests]   ❌  Failure - build
Error: exit with `FAILURE`: 127
<!-- gh-comment-id:743011804 --> @orihomie commented on GitHub (Dec 11, 2020): ``` ➜ slurpy git:(master) ✗ act -W .github/workflows_test [Tests CI/tests] 🚀 Start image=node:12.6-buster-slim [Tests CI/tests] 🐳 docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] [Tests CI/tests] 🐳 docker cp src=/Users/orkhan.mamedov/PycharmProjects/slurpy/. dst=/github/workspace/~/PycharmProjects/slurpy [Tests CI/tests] ⭐ Run Checkout [Tests CI/tests] ✅ Success - Checkout [Tests CI/tests] ⭐ Run build | /github/workflow/1: line 1: docker: command not found [Tests CI/tests] ❌ Failure - build Error: exit with `FAILURE`: 127 ```
Author
Owner
<!-- gh-comment-id:743093461 --> @catthehacker commented on GitHub (Dec 11, 2020): @orihomie read https://github.com/nektos/act#default-runners-are-intentionally-incomplete and https://github.com/nektos/act/issues/107
Author
Owner

@thomas-schuster commented on GitHub (Dec 14, 2020):

I had some hard time with this, too, but after some digging through the code I found out that in order to get the correct dst path you have to provide the path key in the actions/checkout step like this:

steps:
  - name: Checkout
    uses: actions/checkout@v2
    with:
      path: "your-action-root-directory"

I guess this should be better documented in order to save the others the time I had to spend on looking into it.

I am currently stuck at the very same thing. I'd like to try your suggestion, but somehow I do not understand what "your-action-root-directory" would be. Could you exemplify which directory I need to put here? And would it be a relative or absolute path on my machine to get act working?

<!-- gh-comment-id:744428603 --> @thomas-schuster commented on GitHub (Dec 14, 2020): > > > I had some hard time with this, too, but after some digging through the code I found out that in order to get the correct `dst` path you have to provide the `path` key in the `actions/checkout` step like this: > > ```yaml > steps: > - name: Checkout > uses: actions/checkout@v2 > with: > path: "your-action-root-directory" > ``` > > I guess this should be better documented in order to save the others the time I had to spend on looking into it. I am currently stuck at the very same thing. I'd like to try your suggestion, but somehow I do not understand what "your-action-root-directory" would be. Could you exemplify which directory I need to put here? And would it be a relative or absolute path on my machine to get act working?
Author
Owner

@tamj0rd2 commented on GitHub (Jan 1, 2021):

I have a similar question. I'm not sure what "your-action-root-directory" is referring to, because I have no custom actions. Here's a repository I'm working with as an example: https://github.com/tamj0rd2/ts-quickfixes

My ci workflow is defined in .github/workflows/ci.yml. Is that the thing the path is supposed to refer to, or is it something else? Can anyone post a working example of their path parameter and their folder structure?

Here's the error output I'm getting:

[CI/Tests-2] ⭐  Run Run headless test
[CI/Tests-2]   ☁  git clone 'https://github.com/GabrielBB/xvfb-action' # ref=v1.0
[CI/Tests-2]   🐳  docker cp src=/Users/tamara/.cache/act/GabrielBB-xvfb-action@v1.0 dst=/actions/
[CI/Tests-2]   ❗  ::error::Unable to locate executable file: sudo. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
[CI/Tests-2]   ❌  Failure - Run headless test
Error: exit with `FAILURE`: 1
<!-- gh-comment-id:753375358 --> @tamj0rd2 commented on GitHub (Jan 1, 2021): I have a similar question. I'm not sure what "your-action-root-directory" is referring to, because I have no custom actions. Here's a repository I'm working with as an example: https://github.com/tamj0rd2/ts-quickfixes My `ci` workflow is defined in .github/workflows/ci.yml. Is that the thing the path is supposed to refer to, or is it something else? Can anyone post a working example of their path parameter and their folder structure? Here's the error output I'm getting: ``` [CI/Tests-2] ⭐ Run Run headless test [CI/Tests-2] ☁ git clone 'https://github.com/GabrielBB/xvfb-action' # ref=v1.0 [CI/Tests-2] 🐳 docker cp src=/Users/tamara/.cache/act/GabrielBB-xvfb-action@v1.0 dst=/actions/ [CI/Tests-2] ❗ ::error::Unable to locate executable file: sudo. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable. [CI/Tests-2] ❌ Failure - Run headless test Error: exit with `FAILURE`: 1 ```
Author
Owner

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

@tamj0rd2 your issue is not related to #228. You are using docker image that doesn't have sudo included.

<!-- gh-comment-id:753415818 --> @catthehacker commented on GitHub (Jan 2, 2021): @tamj0rd2 your issue is not related to #228. You are using docker image that doesn't have `sudo` included.
Author
Owner

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

Another scenario to help others debug: running this tool in Windows (from Powershell), I received the following error message when I tried to run an action on ubuntu-18.04:

Error: Cannot find module '/github/workspace/\actions\actions-setup-python@v2\dist\index.js'

Note the slash confusion. As an alternative, I opened up a WSL2-based bash prompt and installed act inside of the Linux subsystem. This resolved the slash problem. and I no longer get the module not found error.

<!-- gh-comment-id:764997525 --> @stephenfuqua commented on GitHub (Jan 21, 2021): Another scenario to help others debug: running this tool in Windows (from Powershell), I received the following error message when I tried to run an action on `ubuntu-18.04`: ```bash Error: Cannot find module '/github/workspace/\actions\actions-setup-python@v2\dist\index.js' ``` Note the slash confusion. As an alternative, I opened up a WSL2-based bash prompt and installed `act` inside of the Linux subsystem. This resolved the slash problem. and I no longer get the module not found error.
Author
Owner

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

@stephenfuqua that has been fixed in #461

<!-- gh-comment-id:765168095 --> @catthehacker commented on GitHub (Jan 22, 2021): @stephenfuqua that has been fixed in #461
Author
Owner

@0-sv commented on GitHub (Aug 18, 2021):

@rstuven thanks for pointing this out, but I was able to add a !tsconfig.json line to my .gitignore (just in the same repo as the workflow). For some reason tsconfig.json wasn't copied over. So, although you set me on the correct path, I'm not sure if it's still true.

<!-- gh-comment-id:900942879 --> @0-sv commented on GitHub (Aug 18, 2021): @rstuven thanks for pointing this out, but I was able to add a `!tsconfig.json` line to my `.gitignore` (just in the same repo as the workflow). For some reason `tsconfig.json` wasn't copied over. So, although you set me on the correct path, I'm not sure if it's still true.
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#158
No description provided.