[GH-ISSUE #1982] defaults.run.working-directory option not being respected #951

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

Originally created by @luisaveiro on GitHub (Aug 22, 2023).
Original GitHub issue: https://github.com/nektos/act/issues/1982

Bug report info

act version:            0.2.49
GOOS:                   darwin
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
        /var/run/docker.sock
        $HOME/.docker/run/docker.sock
Config files:           
        /Users/luisaveiro/.actrc:
                -P ubuntu-latest=node:16-buster-slim
                -P ubuntu-22.04=node:16-bullseye-slim
                -P ubuntu-20.04=node:16-buster-slim
                -P ubuntu-18.04=node:16-buster-slim
Build info:
        Go version:            go1.20.6
        Module path:           command-line-arguments
        Main version:          
        Main path:             
        Main checksum:         
        Build settings:
                -buildmode:           exe
                -compiler:            gc
                -ldflags:             -X main.version=0.2.49
                CGO_ENABLED:          1
                CGO_CFLAGS:           
                CGO_CPPFLAGS:         
                CGO_CXXFLAGS:         
                CGO_LDFLAGS:          
                GOARCH:               amd64
                GOOS:                 darwin
                GOAMD64:              v1
Docker Engine:
        Engine version:        24.0.2
        Engine runtime:        runc
        Cgroup version:        2
        Cgroup driver:         cgroupfs
        Storage driver:        overlay2
        Registry URI:          https://index.docker.io/v1/
        OS:                    Docker Desktop
        OS type:               linux
        OS version:            
        OS arch:               x86_64
        OS kernel:             5.15.49-linuxkit-pr
        OS CPU:                8
        OS memory:             7958 MB
        Security options:
                name=seccomp,profile=builtin
                name=cgroupns

Command used with act

act --rm --matrix node-version:18.x

Describe issue

When using GitHub Actions defaults.run.working-directory, act doesn't apply the working-directory as workdir.

act is running on the following directory:

/Users/luisaveiro/Dev/projects/http-client

The GitHub Actions workflow defined the working-directory to be /.code.

/Users/luisaveiro/Dev/projects/http-client/code

No response

Workflow content

name: Pull Request

on: pull_request

defaults:
  run:
    working-directory: ./code

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [14.x, 16.x, 18.x]

    steps:
      - name: Checkout the Git repository
        uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'yarn'
      - name: Install Node Modules
        run: yarn install --immutable --immutable-cache --check-cache
      - name: Run Vitest
        run: yarn run test:ci

Relevant log output

[Pull Request/build] 🚀  Start image=node:16-buster-slim
[Pull Request/build]   🐳  docker pull image=node:16-buster-slim platform= username= forcePull=true
[Pull Request/build]   🐳  docker create image=node:16-buster-slim platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[Pull Request/build]   🐳  docker run image=node:16-buster-slim platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[Pull Request/build]   ☁  git clone 'https://github.com/actions/setup-node' # ref=v3
[Pull Request/build] 🧪  Matrix: map[node-version:18.x]
[Pull Request/build] ⭐ Run Main Checkout the Git repository
[Pull Request/build]   🐳  docker cp src=/Users/luisaveiro/Dev/projects/http-client/. dst=/Users/luisaveiro/Dev/projects/http-client
[Pull Request/build]   ✅  Success - Main Checkout the Git repository
[Pull Request/build] ⭐ Run Main Use Node.js 18.x
[Pull Request/build]   🐳  docker cp src=/Users/luisaveiro/.cache/act/actions-setup-node@v3/ dst=/var/run/act/actions/actions-setup-node@v3/
[Pull Request/build]   🐳  docker exec cmd=[node /var/run/act/actions/actions-setup-node@v3/dist/setup/index.js] user= workdir=
[Pull Request/build]   💬  ::debug::isExplicit: 
[Pull Request/build]   💬  ::debug::explicit? false
[Pull Request/build]   💬  ::debug::evaluating 0 versions
[Pull Request/build]   💬  ::debug::match not found
| Attempting to download 18.x...
[Pull Request/build]   💬  ::debug::No manifest cached
[Pull Request/build]   💬  ::debug::Getting manifest from actions/node-versions@main
[Pull Request/build]   💬  ::debug::check 20.5.1 satisfies 18.x
[Pull Request/build]   💬  ::debug::check 20.5.0 satisfies 18.x
[Pull Request/build]   💬  ::debug::check 20.4.0 satisfies 18.x
[Pull Request/build]   💬  ::debug::check 20.3.1 satisfies 18.x
[Pull Request/build]   💬  ::debug::check 20.3.0 satisfies 18.x
[Pull Request/build]   💬  ::debug::check 20.2.0 satisfies 18.x
[Pull Request/build]   💬  ::debug::check 20.1.0 satisfies 18.x
[Pull Request/build]   💬  ::debug::check 20.0.0 satisfies 18.x
[Pull Request/build]   💬  ::debug::check 18.17.1 satisfies 18.x
[Pull Request/build]   💬  ::debug::x64===x64 && darwin===linux
[Pull Request/build]   💬  ::debug::x64===x64 && linux===linux
[Pull Request/build]   💬  ::debug::matched 18.17.1
| Acquiring 18.17.1 - x64 from https://github.com/actions/node-versions/releases/download/18.17.1-5819737873/node-18.17.1-linux-x64.tar.gz
[Pull Request/build]   💬  ::debug::Downloading https://github.com/actions/node-versions/releases/download/18.17.1-5819737873/node-18.17.1-linux-x64.tar.gz
[Pull Request/build]   💬  ::debug::Destination /tmp/57e463c3-5839-43ec-a977-81cb1258cb60
[Pull Request/build]   💬  ::debug::download complete
| Extracting ...
[Pull Request/build]   💬  ::debug::Checking tar --version
[Pull Request/build]   💬  ::debug::tar (GNU tar) 1.30%0ACopyright (C) 2017 Free Software Foundation, Inc.%0ALicense GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.%0AThis is free software: you are free to change and redistribute it.%0AThere is NO WARRANTY, to the extent permitted by law.%0A%0AWritten by John Gilmore and Jay Fenlason.
| [command]/bin/tar xz --strip 1 --warning=no-unknown-keyword -C /tmp/9d34f5a1-751b-4f3b-ba97-f518e2bda2db -f /tmp/57e463c3-5839-43ec-a977-81cb1258cb60
| Adding to the cache ...
[Pull Request/build]   💬  ::debug::Caching tool node 18.17.1 x64
[Pull Request/build]   💬  ::debug::source dir: /tmp/9d34f5a1-751b-4f3b-ba97-f518e2bda2db
[Pull Request/build]   💬  ::debug::destination /opt/hostedtoolcache/node/18.17.1/x64
[Pull Request/build]   💬  ::debug::finished caching tool
[Pull Request/build]   ❓  ::group::Environment details
| node: v18.17.1
| npm: 9.6.7
| yarn: 1.22.19
[Pull Request/build]   ❓  ::endgroup::
| [command]/usr/local/bin/yarn --version
| 1.22.19
[Pull Request/build]   💬  ::debug::Consumed yarn version is 1.22.19 (working dir: "")
| [command]/usr/local/bin/yarn cache dir
| /usr/local/share/.cache/yarn/v6
[Pull Request/build]   💬  ::debug::yarn's cache folder "/usr/local/share/.cache/yarn/v6" configured for the root directory
[Pull Request/build]   ❗  ::error::Dependencies lock file is not found in /Users/luisaveiro/Dev/projects/http-client. Supported file patterns: yarn.lock
[Pull Request/build]   ❌  Failure - Main Use Node.js 18.x
[Pull Request/build]   ⚙  ::set-output:: node-version=v18.17.1
[Pull Request/build]   ⚙  ::add-path:: /opt/hostedtoolcache/node/18.17.1/x64/bin
[Pull Request/build] exitcode '1': failure
[Pull Request/build] 🏁  Job failed
Error: Job 'build' failed

Additional information

No response

Originally created by @luisaveiro on GitHub (Aug 22, 2023). Original GitHub issue: https://github.com/nektos/act/issues/1982 ### Bug report info ```plain text act version: 0.2.49 GOOS: darwin GOARCH: amd64 NumCPU: 16 Docker host: DOCKER_HOST environment variable is not set Sockets found: /var/run/docker.sock $HOME/.docker/run/docker.sock Config files: /Users/luisaveiro/.actrc: -P ubuntu-latest=node:16-buster-slim -P ubuntu-22.04=node:16-bullseye-slim -P ubuntu-20.04=node:16-buster-slim -P ubuntu-18.04=node:16-buster-slim Build info: Go version: go1.20.6 Module path: command-line-arguments Main version: Main path: Main checksum: Build settings: -buildmode: exe -compiler: gc -ldflags: -X main.version=0.2.49 CGO_ENABLED: 1 CGO_CFLAGS: CGO_CPPFLAGS: CGO_CXXFLAGS: CGO_LDFLAGS: GOARCH: amd64 GOOS: darwin GOAMD64: v1 Docker Engine: Engine version: 24.0.2 Engine runtime: runc Cgroup version: 2 Cgroup driver: cgroupfs Storage driver: overlay2 Registry URI: https://index.docker.io/v1/ OS: Docker Desktop OS type: linux OS version: OS arch: x86_64 OS kernel: 5.15.49-linuxkit-pr OS CPU: 8 OS memory: 7958 MB Security options: name=seccomp,profile=builtin name=cgroupns ``` ### Command used with act ```sh act --rm --matrix node-version:18.x ``` ### Describe issue When using GitHub Actions [defaults.run.working-directory](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun), act doesn't apply the `working-directory` as workdir. act is running on the following directory: ``` /Users/luisaveiro/Dev/projects/http-client ``` The GitHub Actions workflow defined the working-directory to be `/.code`. ``` /Users/luisaveiro/Dev/projects/http-client/code ``` ### Link to GitHub repository _No response_ ### Workflow content ```yml name: Pull Request on: pull_request defaults: run: working-directory: ./code jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [14.x, 16.x, 18.x] steps: - name: Checkout the Git repository uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} cache: 'yarn' - name: Install Node Modules run: yarn install --immutable --immutable-cache --check-cache - name: Run Vitest run: yarn run test:ci ``` ### Relevant log output ```sh [Pull Request/build] 🚀 Start image=node:16-buster-slim [Pull Request/build] 🐳 docker pull image=node:16-buster-slim platform= username= forcePull=true [Pull Request/build] 🐳 docker create image=node:16-buster-slim platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] [Pull Request/build] 🐳 docker run image=node:16-buster-slim platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] [Pull Request/build] ☁ git clone 'https://github.com/actions/setup-node' # ref=v3 [Pull Request/build] 🧪 Matrix: map[node-version:18.x] [Pull Request/build] ⭐ Run Main Checkout the Git repository [Pull Request/build] 🐳 docker cp src=/Users/luisaveiro/Dev/projects/http-client/. dst=/Users/luisaveiro/Dev/projects/http-client [Pull Request/build] ✅ Success - Main Checkout the Git repository [Pull Request/build] ⭐ Run Main Use Node.js 18.x [Pull Request/build] 🐳 docker cp src=/Users/luisaveiro/.cache/act/actions-setup-node@v3/ dst=/var/run/act/actions/actions-setup-node@v3/ [Pull Request/build] 🐳 docker exec cmd=[node /var/run/act/actions/actions-setup-node@v3/dist/setup/index.js] user= workdir= [Pull Request/build] 💬 ::debug::isExplicit: [Pull Request/build] 💬 ::debug::explicit? false [Pull Request/build] 💬 ::debug::evaluating 0 versions [Pull Request/build] 💬 ::debug::match not found | Attempting to download 18.x... [Pull Request/build] 💬 ::debug::No manifest cached [Pull Request/build] 💬 ::debug::Getting manifest from actions/node-versions@main [Pull Request/build] 💬 ::debug::check 20.5.1 satisfies 18.x [Pull Request/build] 💬 ::debug::check 20.5.0 satisfies 18.x [Pull Request/build] 💬 ::debug::check 20.4.0 satisfies 18.x [Pull Request/build] 💬 ::debug::check 20.3.1 satisfies 18.x [Pull Request/build] 💬 ::debug::check 20.3.0 satisfies 18.x [Pull Request/build] 💬 ::debug::check 20.2.0 satisfies 18.x [Pull Request/build] 💬 ::debug::check 20.1.0 satisfies 18.x [Pull Request/build] 💬 ::debug::check 20.0.0 satisfies 18.x [Pull Request/build] 💬 ::debug::check 18.17.1 satisfies 18.x [Pull Request/build] 💬 ::debug::x64===x64 && darwin===linux [Pull Request/build] 💬 ::debug::x64===x64 && linux===linux [Pull Request/build] 💬 ::debug::matched 18.17.1 | Acquiring 18.17.1 - x64 from https://github.com/actions/node-versions/releases/download/18.17.1-5819737873/node-18.17.1-linux-x64.tar.gz [Pull Request/build] 💬 ::debug::Downloading https://github.com/actions/node-versions/releases/download/18.17.1-5819737873/node-18.17.1-linux-x64.tar.gz [Pull Request/build] 💬 ::debug::Destination /tmp/57e463c3-5839-43ec-a977-81cb1258cb60 [Pull Request/build] 💬 ::debug::download complete | Extracting ... [Pull Request/build] 💬 ::debug::Checking tar --version [Pull Request/build] 💬 ::debug::tar (GNU tar) 1.30%0ACopyright (C) 2017 Free Software Foundation, Inc.%0ALicense GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.%0AThis is free software: you are free to change and redistribute it.%0AThere is NO WARRANTY, to the extent permitted by law.%0A%0AWritten by John Gilmore and Jay Fenlason. | [command]/bin/tar xz --strip 1 --warning=no-unknown-keyword -C /tmp/9d34f5a1-751b-4f3b-ba97-f518e2bda2db -f /tmp/57e463c3-5839-43ec-a977-81cb1258cb60 | Adding to the cache ... [Pull Request/build] 💬 ::debug::Caching tool node 18.17.1 x64 [Pull Request/build] 💬 ::debug::source dir: /tmp/9d34f5a1-751b-4f3b-ba97-f518e2bda2db [Pull Request/build] 💬 ::debug::destination /opt/hostedtoolcache/node/18.17.1/x64 [Pull Request/build] 💬 ::debug::finished caching tool [Pull Request/build] ❓ ::group::Environment details | node: v18.17.1 | npm: 9.6.7 | yarn: 1.22.19 [Pull Request/build] ❓ ::endgroup:: | [command]/usr/local/bin/yarn --version | 1.22.19 [Pull Request/build] 💬 ::debug::Consumed yarn version is 1.22.19 (working dir: "") | [command]/usr/local/bin/yarn cache dir | /usr/local/share/.cache/yarn/v6 [Pull Request/build] 💬 ::debug::yarn's cache folder "/usr/local/share/.cache/yarn/v6" configured for the root directory [Pull Request/build] ❗ ::error::Dependencies lock file is not found in /Users/luisaveiro/Dev/projects/http-client. Supported file patterns: yarn.lock [Pull Request/build] ❌ Failure - Main Use Node.js 18.x [Pull Request/build] ⚙ ::set-output:: node-version=v18.17.1 [Pull Request/build] ⚙ ::add-path:: /opt/hostedtoolcache/node/18.17.1/x64/bin [Pull Request/build] exitcode '1': failure [Pull Request/build] 🏁 Job failed Error: Job 'build' failed ``` ### Additional information _No response_
kerem 2026-03-01 21:47:40 +03:00
Author
Owner

@ChristopherHX commented on GitHub (Aug 22, 2023):

Sorry but this open source project is not for requesting features for the GitHub Actions platform.

I want to remind you, what you are doing here is not respected by the official GitHub Actions Runner

In short the key is not named defaults.uses.working-directory, to imply it applies to steps with run key.

<!-- gh-comment-id:1689013702 --> @ChristopherHX commented on GitHub (Aug 22, 2023): Sorry but this open source project is not for requesting features for the GitHub Actions platform. I want to remind you, what you are doing here is not respected by the official GitHub Actions Runner In short the key is not named defaults.uses.working-directory, to imply it applies to steps with `run` key.
Author
Owner

@luisaveiro commented on GitHub (Aug 23, 2023):

@ChristopherHX thank you for your response. I might not have articulated my message correctly. I'm sorry for any confusion.

I have a GitHub Actions workflow I'm trying to validate & test locally using the Act tool. I'm experiencing a behavioural issue with Act not respecting the GitHub Actions syntax option for jobs.<job_id>.defaults.run.working-directory.

According to GitHub Actions documentation

You can use defaults.run to provide default shell and working-directory options for all run steps in a workflow. You can also set default settings for run that are only available to a job. For more information, see jobs.<job_id>.defaults.run. You cannot use contexts or expressions in this keyword.

Example: Set the default working directory
defaults:
  run:
    working-directory: scripts

My GitHub Actions workflow does work with GitHub as expected. I was under the impression that the Act tool supported the entire GitHub Actions syntax options.

<!-- gh-comment-id:1690698772 --> @luisaveiro commented on GitHub (Aug 23, 2023): @ChristopherHX thank you for your response. I might not have articulated my message correctly. I'm sorry for any confusion. I have a GitHub Actions workflow I'm trying to validate & test locally using the Act tool. I'm experiencing a behavioural issue with Act not respecting the GitHub Actions syntax option for `jobs.<job_id>.defaults.run.working-directory`. ##### According to [GitHub Actions documentation](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun) > You can use defaults.run to provide default shell and working-directory options for all [run](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun) steps in a workflow. You can also set default settings for run that are only available to a job. For more information, see [jobs.<job_id>.defaults.run](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun). You cannot use contexts or expressions in this keyword. ##### Example: Set the default working directory ``` defaults: run: working-directory: scripts ``` My GitHub Actions workflow does work with GitHub as expected. I was under the impression that the Act tool supported the entire GitHub Actions syntax options.
Author
Owner

@ChristopherHX commented on GitHub (Aug 23, 2023):

But "Main Use Node.js 18.x" is a nodejs action and not a run step, how does that work on GitHub?

The source code of actions runner ignores any attempt to change the working-directory of

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'yarn' # If you disable caching it will work

and so does act.

<!-- gh-comment-id:1690719285 --> @ChristopherHX commented on GitHub (Aug 23, 2023): But "Main Use Node.js 18.x" is a nodejs action and not a run step, how does that work on GitHub? The source code of actions runner ignores any attempt to change the working-directory of ```yaml - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} cache: 'yarn' # If you disable caching it will work ``` and so does act.
Author
Owner

@luisaveiro commented on GitHub (Aug 24, 2023):

@ChristopherHX I found the issue. I modified the GitHub Actions incorrectly while testing with the Act tool. I moved the defaults.run.working-directory option outside of the jobs.build. I reverted this change and the GitHub Actions is working with the Act tool. Thanks for your support.

name: Pull Request

on: pull_request

jobs:
  build:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./code

    strategy:
      matrix:
        node-version: [16.x, 18.x, 20.x]

    steps:
      - name: Checkout the Git repository
        uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
      - name: Install Node Modules
        run: yarn install --immutable --immutable-cache --check-cache
      - name: Run Vitest
        run: yarn run test:ci

<!-- gh-comment-id:1692285362 --> @luisaveiro commented on GitHub (Aug 24, 2023): @ChristopherHX I found the issue. I modified the GitHub Actions incorrectly while testing with the Act tool. I moved the `defaults.run.working-directory` option outside of the `jobs.build`. I reverted this change and the GitHub Actions is working with the Act tool. Thanks for your support. ```yaml name: Pull Request on: pull_request jobs: build: runs-on: ubuntu-latest defaults: run: working-directory: ./code strategy: matrix: node-version: [16.x, 18.x, 20.x] steps: - name: Checkout the Git repository uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Install Node Modules run: yarn install --immutable --immutable-cache --check-cache - name: Run Vitest run: yarn run test:ci ```
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#951
No description provided.