[GH-ISSUE #2024] 'MODULE_NOT_FOUND' resulting from configuration of working directory when using host environment #971

Closed
opened 2026-03-01 21:47:49 +03:00 by kerem · 12 comments
Owner

Originally created by @colonelpanic8 on GitHub (Sep 24, 2023).
Original GitHub issue: https://github.com/nektos/act/issues/2024

Bug report info

I filed this issue against the gitea act_runner (https://gitea.com/gitea/act_runner/issues/361), but having read some more code, I believe that the issue lies in the way that act is configured.

I've done some digging and I believe I (sort of) understand why the problem is happening, but I can't say I fully understand the design of the host environment, or what is supposed to be happening.

Here is a gist of the output i see from the gitea runner:

https://gist.github.com/colonelpanic8/37ff6b474e9c6475d599ee2e8de5accd

The most important line from this is:

type=remote-action actionDir=.cache/act/actions-checkout@v2 actionPath= workdir=//var/lib/gitea-runner/workspace/billnerds/railbird actionCacheDir=.cache/act actionName=actions-checkout@v2 containerActionDir=.cache/act/5b246fa22da6d129/act/actions/actions-checkout@v2
Removing .cache/act/actions-checkout@v2/.gitignore before docker cp`
```/var/lib/gitea-runner/nix/.cache/act/182e52eeaf6a06cd/act/actions/actions-checkout@v2/

Now, note that when the actual checkout command is executed, it seems we are looking for it here:

/var/lib/private/gitea-runner/nix/.cache/act/5b246fa22da6d129/hostexecutor/.cache/act/5b246fa22da6d129/act/actions/actions-checkout@v2/dist/index.js

when this file actually exists

/var/lib/gitea-runner/nix/.cache/act/182e52eeaf6a06cd/act/actions/actions-checkout@v2/dist/index.js

So the mystery, is basically, why is there an additional:
hostexecutor/.cache/act/5b246fa22da6d129/

in the middle of the path here?

I belive, I sort of understand what is going on, but again, I don't fully understand the design of act, so I'm not sure what the right way to fix this is. Anyway, let me elaborate:

The log line that gives us information about paths occurs here:

github.com/nektos/act@c241ecda31/pkg/runner/action.go (L151)

We can see that this results in a call for the action here:

github.com/nektos/act@c241ecda31/pkg/runner/action.go (L163)

After a few jumps, you can see that results in this call:

github.com/nektos/act@c241ecda31/pkg/container/host_environment.go (L284)

which, given that we set the working directory to empty, will set the working directory to the HostEnvironment's Path, here:

github.com/nektos/act@c241ecda31/pkg/container/host_environment.go (L294)

this field is initialized here:

github.com/nektos/act@c241ecda31/pkg/runner/run_context.go (L180)

which we can see joins miscpath to that path "hostexecutor"

so pretty clearly, this is where we are getting this extra piece of path.

I'm just really confused about how this codepath could ever work. There is never any way the action stuff is going to be copied to a path with this hostexecutor thing in there.

I feel like maybethis maybeCopyToActionDir (github.com/nektos/act@c241ecda31/pkg/runner/action.go (L155)) is sort of meant to take care of this, but if you look at all the relevant variables, its pretty clear that this is not going to happen.

It seems like maybe the solution might be to appropriately set the working directory here:

github.com/nektos/act@c241ecda31/pkg/runner/action.go (L163)



### Command used with act

```sh
ff

Describe issue

ffMain

No response

Workflow content

ff

Relevant log output

ff

Additional information

No response

Originally created by @colonelpanic8 on GitHub (Sep 24, 2023). Original GitHub issue: https://github.com/nektos/act/issues/2024 ### Bug report info I filed this issue against the gitea act_runner (https://gitea.com/gitea/act_runner/issues/361), but having read some more code, I believe that the issue lies in the way that act is configured. I've done some digging and I believe I (sort of) understand why the problem is happening, but I can't say I fully understand the design of the host environment, or what is supposed to be happening. Here is a gist of the output i see from the gitea runner: https://gist.github.com/colonelpanic8/37ff6b474e9c6475d599ee2e8de5accd The most important line from this is: ``` type=remote-action actionDir=.cache/act/actions-checkout@v2 actionPath= workdir=//var/lib/gitea-runner/workspace/billnerds/railbird actionCacheDir=.cache/act actionName=actions-checkout@v2 containerActionDir=.cache/act/5b246fa22da6d129/act/actions/actions-checkout@v2 Removing .cache/act/actions-checkout@v2/.gitignore before docker cp` ```/var/lib/gitea-runner/nix/.cache/act/182e52eeaf6a06cd/act/actions/actions-checkout@v2/ ``` Now, note that when the actual checkout command is executed, it seems we are looking for it here: /var/lib/private/gitea-runner/nix/.cache/act/5b246fa22da6d129/hostexecutor/.cache/act/5b246fa22da6d129/act/actions/actions-checkout@v2/dist/index.js when this file actually exists /var/lib/gitea-runner/nix/.cache/act/182e52eeaf6a06cd/act/actions/actions-checkout@v2/dist/index.js So the mystery, is basically, why is there an additional: hostexecutor/.cache/act/5b246fa22da6d129/ in the middle of the path here? I belive, I sort of understand what is going on, but again, I don't fully understand the design of act, so I'm not sure what the right way to fix this is. Anyway, let me elaborate: The log line that gives us information about paths occurs here: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/action.go#L151 We can see that this results in a call for the action here: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/action.go#L163 After a few jumps, you can see that results in this call: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/container/host_environment.go#L284 which, given that we set the working directory to empty, will set the working directory to the HostEnvironment's Path, here: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/container/host_environment.go#L294 this field is initialized here: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/run_context.go#L180 which we can see joins miscpath to that path "hostexecutor" so pretty clearly, this is where we are getting this extra piece of path. I'm just really confused about how this codepath could ever work. There is never any way the action stuff is going to be copied to a path with this hostexecutor thing in there. I feel like maybethis maybeCopyToActionDir (https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/action.go#L155) is sort of meant to take care of this, but if you look at all the relevant variables, its pretty clear that this is not going to happen. It seems like maybe the solution might be to appropriately set the working directory here: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/action.go#L163 ``` ### Command used with act ```sh ff ``` ### Describe issue ffMain ### Link to GitHub repository _No response_ ### Workflow content ```yml ff ``` ### Relevant log output ```sh ff ``` ### Additional information _No response_
Author
Owner

@colonelpanic8 commented on GitHub (Sep 24, 2023):

Honestly, the easiest thing to do, might simply be to make sure that:

getContainerActionPaths

is returning an appropriate path for the host environment:

github.com/nektos/act@c241ecda31/pkg/runner/action.go (L413)

<!-- gh-comment-id:1732675399 --> @colonelpanic8 commented on GitHub (Sep 24, 2023): Honestly, the easiest thing to do, might simply be to make sure that: getContainerActionPaths is returning an appropriate path for the host environment: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/action.go#L413
Author
Owner

@ChristopherHX commented on GitHub (Sep 24, 2023):

Sounds like a problem in gitea/act.

/act/actions is not present here and not all maintainer of the fork fully understand what they change.

The path is correct in act e.g. act -P mylabel=-self-hosted will behave

configuration of working directory

You cannot configure it in any meaningful ways in nektos/act, must be part of gitea/act

<!-- gh-comment-id:1732676891 --> @ChristopherHX commented on GitHub (Sep 24, 2023): Sounds like a problem in gitea/act. `/act/actions` is not present here and not all maintainer of the fork fully understand what they change. The path is correct in act e.g. `act -P mylabel=-self-hosted` will behave > configuration of working directory You cannot configure it in any meaningful ways in nektos/act, must be part of gitea/act
Author
Owner

@colonelpanic8 commented on GitHub (Sep 24, 2023):

Sounds like a problem in gitea/act.

Can you elaborate on why you think this?

Did you look at all the links that I posted?

It could happen to work in act, because act happens to set up certain directories to agree. That doesn't mean that the code is necessarily correct.

In particular, can you explain how this:

github.com/nektos/act@c241ecda31/pkg/runner/run_context.go (L180)

makes any sense at all?

<!-- gh-comment-id:1732677428 --> @colonelpanic8 commented on GitHub (Sep 24, 2023): > Sounds like a problem in gitea/act. Can you elaborate on why you think this? Did you look at all the links that I posted? It could *happen* to work in act, because act happens to set up certain directories to agree. That doesn't mean that the code is necessarily correct. In particular, can you explain how this: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/run_context.go#L180 makes any sense at all?
Author
Owner

@ChristopherHX commented on GitHub (Sep 24, 2023):

  • hostexecutor is a subdirectory for the workspace
  • the other folders are for remote actions that are normally copied inside the container, but needs an destination folder on the host
<!-- gh-comment-id:1732678123 --> @ChristopherHX commented on GitHub (Sep 24, 2023): - hostexecutor is a subdirectory for the workspace - the other folders are for remote actions that are normally copied inside the container, but needs an destination folder on the host
Author
Owner

@colonelpanic8 commented on GitHub (Sep 24, 2023):

In particular, this does not make any sense to me:

When we get the container actions path:

github.com/nektos/act@c241ecda31/pkg/runner/action.go (L422)

we will ultimately set it to the result of a call to here:

github.com/nektos/act@c241ecda31/pkg/container/host_environment.go (L396)

This is initialized here:

github.com/nektos/act@c241ecda31/pkg/runner/run_context.go (L176)

and will be quite a different directory than what is used as the default working directory, which is here:

github.com/nektos/act@c241ecda31/pkg/runner/run_context.go (L180)

<!-- gh-comment-id:1732678301 --> @colonelpanic8 commented on GitHub (Sep 24, 2023): In particular, this does not make any sense to me: When we get the container actions path: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/action.go#L422 we will ultimately set it to the result of a call to here: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/container/host_environment.go#L396 This is initialized here: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/run_context.go#L176 and will be quite a different directory than what is used as the default working directory, which is here: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/run_context.go#L180
Author
Owner

@colonelpanic8 commented on GitHub (Sep 24, 2023):

  • the other folders are for remote actions that are normally copied inside the container, but needs an destination folder on the host

sure, but then the way the working directory is set here:

github.com/nektos/act@c241ecda31/pkg/container/host_environment.go (L287)

isn't going to work with the way we are trying to call the remote action here:

github.com/nektos/act@c241ecda31/pkg/runner/action.go (L163)

I mean to me, its crystal clear why this is failing in my case.

<!-- gh-comment-id:1732679437 --> @colonelpanic8 commented on GitHub (Sep 24, 2023): > * the other folders are for remote actions that are normally copied inside the container, but needs an destination folder on the host sure, but then the way the working directory is set here: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/container/host_environment.go#L287 isn't going to work with the way we are trying to call the remote action here: https://github.com/nektos/act/blob/c241ecda318e4977501971c267f0a2fad70ea5cd/pkg/runner/action.go#L163 I mean to me, its crystal clear why this is failing in my case.
Author
Owner

@ChristopherHX commented on GitHub (Sep 24, 2023):

remote actions like checkout should not be copied to the default working directory. (actpath is /var/run/act for docker backend)

Doing so will override files of your repository.

Keep in mind that node shall be called with an absolute path, while your log shows a relative path and that cannot work

I use this code since Summer 2021 and it works without such issue.

Please look at the source code used by act_runner, it's not the same

<!-- gh-comment-id:1732679744 --> @ChristopherHX commented on GitHub (Sep 24, 2023): remote actions like checkout should not be copied to the default working directory. (actpath is /var/run/act for docker backend) Doing so will override files of your repository. Keep in mind that node shall be called with an absolute path, while your log shows a relative path and that cannot work I use this code since Summer 2021 and it works without such issue. Please look at the source code used by act_runner, it's not the same
Author
Owner

@ChristopherHX commented on GitHub (Sep 24, 2023):

I can imagine that your HOME env var is absent, my github-act-runner warns you about this and applies a hotfix

<!-- gh-comment-id:1732680154 --> @ChristopherHX commented on GitHub (Sep 24, 2023): I can imagine that your `HOME` env var is absent, my github-act-runner warns you about this and applies a hotfix
Author
Owner

@colonelpanic8 commented on GitHub (Sep 24, 2023):

Keep in mind that node shall be called with an absolute path

well there we do at least agree. I still think something is obviously fundamentally wrong with this code, because its clearly written as though its possible to use relative paths!

very sloppy coding all around if you ask me.

<!-- gh-comment-id:1732680249 --> @colonelpanic8 commented on GitHub (Sep 24, 2023): > Keep in mind that node shall be called with an absolute path well there we do at least agree. I still think something is obviously fundamentally wrong with this code, because its clearly written as though its possible to use relative paths! very sloppy coding all around if you ask me.
Author
Owner

@ChristopherHX commented on GitHub (Sep 25, 2023):

very sloppy coding all around if you ask me.

Non careful review by other members / missing test cases in a feature PR, you cannot expect old code to work with relative paths while it was impossible in the past.

The value was based on HOME, XDG_CACHE_HOME, filepath.Abs(".") and os.TempDir(). At this time a relative path was not expected.

Bug caused by github.com/nektos/act@74c27db4dd (Look at the reviewer, I'm not listed)

I prefer to use actions/runner with Gitea Actions (made a tool to allow that), act is too buggy

<!-- gh-comment-id:1733064019 --> @ChristopherHX commented on GitHub (Sep 25, 2023): > very sloppy coding all around if you ask me. Non careful review by other members / missing test cases in a feature PR, you cannot expect old code to work with relative paths while it was impossible in the past. The value was based on HOME, XDG_CACHE_HOME, filepath.Abs(".") and os.TempDir(). At this time a relative path was not expected. Bug caused by https://github.com/nektos/act/commit/74c27db4dd685b1465832c4de73786e397e2a3ce (Look at the reviewer, I'm not listed) _I prefer to use actions/runner with Gitea Actions (made a tool to allow that), act is too buggy_
Author
Owner

@ChristopherHX commented on GitHub (Sep 25, 2023):

Please follow the issue template, because you didn't provde how to reproduce this in nektos/act.

The following breaks

act -W push.yml -P ubuntu-latest=-self-hosted --action-cache-path cwd/actions

At the time hostenvironment has been added, you couldn't use a relative path.

<!-- gh-comment-id:1733070571 --> @ChristopherHX commented on GitHub (Sep 25, 2023): Please follow the issue template, because you didn't provde how to reproduce this in nektos/act. The following breaks ``` act -W push.yml -P ubuntu-latest=-self-hosted --action-cache-path cwd/actions ``` At the time hostenvironment has been added, you couldn't use a relative path.
Author
Owner

@github-actions[bot] commented on GitHub (Mar 24, 2024):

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

<!-- gh-comment-id:2016639513 --> @github-actions[bot] commented on GitHub (Mar 24, 2024): Issue is stale and will be closed in 14 days unless there is new activity
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#971
No description provided.