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

MODULE_NOT_FOUND during docker cp command #228

Closed
pmatheson-greenphire opened this issue May 8, 2020 · 14 comments Β· Fixed by #288
Closed

MODULE_NOT_FOUND during docker cp command #228

pmatheson-greenphire opened this issue May 8, 2020 · 14 comments Β· Fixed by #288
Labels
area/action Relating to running an action kind/bug Something isn't working meta/workaround A workaround has been identified.

Comments

@pmatheson-greenphire
Copy link

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/[email protected] dst=/actions/
| internal/modules/cjs/loader.js:985
|   throw err;
|   ^
| 
| Error: Cannot find module '/actions/[email protected]/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 [email protected] 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/[email protected] /actions/[email protected]

@rdlf0
Copy link

rdlf0 commented 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.

@pmatheson-greenphire
Copy link
Author

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}

@rdlf0
Copy link

rdlf0 commented 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.

@cplee cplee added area/action Relating to running an action kind/bug Something isn't working meta/workaround A workaround has been identified. labels May 13, 2020
@rstuven
Copy link

rstuven commented 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/[email protected]/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: GitTools/actions@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.

@ColinM9991
Copy link

ColinM9991 commented 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

@tyler274
Copy link

tyler274 commented 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

@orihomie
Copy link

➜  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

@catthehacker
Copy link
Member

@thomas-schuster
Copy link

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?

@tamj0rd2
Copy link

tamj0rd2 commented 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/[email protected] 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

@catthehacker
Copy link
Member

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

@stephenfuqua
Copy link

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.

@catthehacker
Copy link
Member

@stephenfuqua that has been fixed in #461

@0-sv
Copy link

0-sv commented 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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/action Relating to running an action kind/bug Something isn't working meta/workaround A workaround has been identified.
Projects
None yet
Development

Successfully merging a pull request may close this issue.