[GH-ISSUE #295] 'needs' is not defined #206

Closed
opened 2026-03-01 21:41:13 +03:00 by kerem · 35 comments
Owner

Originally created by @kochetkovIT on GitHub (Jun 25, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/295

Error ERRO[0002] Unable to interpolate string 'echo ${{ needs.pre.output1 }}' - [ReferenceError: 'needs' is not defined] when try to following workflow:

jobs:
  pre:
    runs-on: ubuntu-latest
    steps:
      - run: echo '::set-env name=VAR1::value1'
    outputs:
      output1: ${{ env.VAR1 }}

  job1:
    runs-on: ubuntu-latest
    needs: [pre]
    steps:
      - run: echo ${{ needs.pre.outputs.output1 }}

This syntax is working in workflow ran by Github Actions, as we do use it in our project's CI.

Originally created by @kochetkovIT on GitHub (Jun 25, 2020). Original GitHub issue: https://github.com/nektos/act/issues/295 Error `ERRO[0002] Unable to interpolate string 'echo ${{ needs.pre.output1 }}' - [ReferenceError: 'needs' is not defined]` when try to following workflow: ``` jobs: pre: runs-on: ubuntu-latest steps: - run: echo '::set-env name=VAR1::value1' outputs: output1: ${{ env.VAR1 }} job1: runs-on: ubuntu-latest needs: [pre] steps: - run: echo ${{ needs.pre.outputs.output1 }} ``` This syntax is working in workflow ran by Github Actions, as we do use it in our project's CI.
Author
Owner

@snipebin commented on GitHub (Jun 30, 2020):

+1

<!-- gh-comment-id:651472933 --> @snipebin commented on GitHub (Jun 30, 2020): +1
Author
Owner

@Nilegfx commented on GitHub (Aug 8, 2020):

any workaround for this?

<!-- gh-comment-id:670943979 --> @Nilegfx commented on GitHub (Aug 8, 2020): any workaround for this?
Author
Owner

@davidwestberry commented on GitHub (Aug 26, 2020):

This feature would be really helpful

<!-- gh-comment-id:680970884 --> @davidwestberry commented on GitHub (Aug 26, 2020): This feature would be really helpful
Author
Owner

@github-actions[bot] commented on GitHub (Oct 26, 2020):

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

<!-- gh-comment-id:716241310 --> @github-actions[bot] commented on GitHub (Oct 26, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@github-actions[bot] commented on GitHub (Jan 16, 2021):

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

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

@matiasalbarello commented on GitHub (Jan 19, 2021):

+1

<!-- gh-comment-id:762727944 --> @matiasalbarello commented on GitHub (Jan 19, 2021): +1
Author
Owner

@njimenezotto commented on GitHub (Jan 27, 2021):

+1

<!-- gh-comment-id:768379615 --> @njimenezotto commented on GitHub (Jan 27, 2021): +1
Author
Owner

@seru1us commented on GitHub (Feb 9, 2021):

+1

<!-- gh-comment-id:776189614 --> @seru1us commented on GitHub (Feb 9, 2021): +1
Author
Owner

@anthonykawa commented on GitHub (Feb 18, 2021):

+1

<!-- gh-comment-id:781144404 --> @anthonykawa commented on GitHub (Feb 18, 2021): +1
Author
Owner

@ch1seL commented on GitHub (Mar 7, 2021):

+1

<!-- gh-comment-id:792322177 --> @ch1seL commented on GitHub (Mar 7, 2021): +1
Author
Owner

@abelcha commented on GitHub (Mar 15, 2021):

+1

<!-- gh-comment-id:799653919 --> @abelcha commented on GitHub (Mar 15, 2021): +1
Author
Owner

@almahmoud commented on GitHub (Mar 23, 2021):

+1

<!-- gh-comment-id:804612440 --> @almahmoud commented on GitHub (Mar 23, 2021): +1
Author
Owner

@nikultimo commented on GitHub (Mar 31, 2021):

+1

<!-- gh-comment-id:811036216 --> @nikultimo commented on GitHub (Mar 31, 2021): +1
Author
Owner

@gcoban commented on GitHub (Apr 11, 2021):

Community needs "needs" :)

<!-- gh-comment-id:817361453 --> @gcoban commented on GitHub (Apr 11, 2021): Community needs "needs" :)
Author
Owner

@gakonst commented on GitHub (Apr 14, 2021):

+1

<!-- gh-comment-id:819923882 --> @gakonst commented on GitHub (Apr 14, 2021): +1
Author
Owner

@Joshuapwilley commented on GitHub (Apr 16, 2021):

This is a huge blocker for us. The "needs" parameter enables proper, efficient parallel jobs to be run that have a common set of steps that need to be run for all of them.

We have a number of applications that build for multiple environments but share several common steps. Without being able to use the "needs" option, we have to resort to duplicating steps and waiting on things to run serially which is FAR less than ideal.

<!-- gh-comment-id:821580215 --> @Joshuapwilley commented on GitHub (Apr 16, 2021): This is a huge blocker for us. The "needs" parameter enables proper, efficient parallel jobs to be run that have a common set of steps that need to be run for all of them. We have a number of applications that build for multiple environments but share several common steps. Without being able to use the "needs" option, we have to resort to duplicating steps and waiting on things to run serially which is FAR less than ideal.
Author
Owner

@agentschmitt commented on GitHub (Apr 19, 2021):

We are also using the needs parameter in many workflows, but this breaks usage of act and we cant test locally anymore.
Adding support for this would be really nice.

<!-- gh-comment-id:822334397 --> @agentschmitt commented on GitHub (Apr 19, 2021): We are also using the needs parameter in many workflows, but this breaks usage of act and we cant test locally anymore. Adding support for this would be really nice.
Author
Owner

@hcguersoy-oc commented on GitHub (Jul 2, 2021):

Unfortunately here the same: needing needs but it blocks simply using act for our development process.

<!-- gh-comment-id:872860784 --> @hcguersoy-oc commented on GitHub (Jul 2, 2021): Unfortunately here the same: needing `needs` but it blocks simply using _act_ for our development process.
Author
Owner

@adamthedog commented on GitHub (Jul 2, 2021):

@hcguersoy-oc
Just wanted to let you know if you didn't notice; the fix was merged yesterday! :) (see: #629 as per mergify update)

<!-- gh-comment-id:873164565 --> @adamthedog commented on GitHub (Jul 2, 2021): @hcguersoy-oc Just wanted to let you know if you didn't notice; the fix was merged yesterday! :) (see: #629 as per `mergify` update)
Author
Owner

@jacksoncougar commented on GitHub (Jul 16, 2021):

When I run this example https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-8

name: Diff AccessDB
on: [pull_request]

jobs:
  job1:
    runs-on: ubuntu-latest
    # Map a step output to a job output
    outputs:
      output1: ${{ steps.step1.outputs.test }}
      output2: ${{ steps.step2.outputs.test }}
    steps:
      - id: step1
        run: echo "::set-output name=test::hello"
      - id: step2
        run: echo "::set-output name=test::world"
  job2:
    runs-on: ubuntu-latest
    needs: job1
    steps:
      - run: echo ${{needs.job1.outputs.output1}} ${{needs.job1.outputs.output2}}

Then I am getting this error in the latest @master version when I run act.

ERRO[0003] Unable to interpolate string '${{ steps.step2.outputs.test }}' - [TypeError: Cannot access member 'outputs' of undefined]

Is this a known limitation?

<!-- gh-comment-id:881627007 --> @jacksoncougar commented on GitHub (Jul 16, 2021): When I run this example https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-8 ```yml name: Diff AccessDB on: [pull_request] jobs: job1: runs-on: ubuntu-latest # Map a step output to a job output outputs: output1: ${{ steps.step1.outputs.test }} output2: ${{ steps.step2.outputs.test }} steps: - id: step1 run: echo "::set-output name=test::hello" - id: step2 run: echo "::set-output name=test::world" job2: runs-on: ubuntu-latest needs: job1 steps: - run: echo ${{needs.job1.outputs.output1}} ${{needs.job1.outputs.output2}} ``` Then I am getting this error in the latest `@master` version when I run act. > ERRO[0003] Unable to interpolate string '${{ steps.step2.outputs.test }}' - [TypeError: Cannot access member 'outputs' of undefined] Is this a known limitation?
Author
Owner

@craigtubb57 commented on GitHub (Jul 16, 2021):

I am seeing the same. It seems to only work with the first step of each job.

<!-- gh-comment-id:881627890 --> @craigtubb57 commented on GitHub (Jul 16, 2021): I am seeing the same. It seems to only work with the first step of each job.
Author
Owner

@Steph0 commented on GitHub (Jul 22, 2021):

Hope the next release is soon with this. Have a hard time convincing my team to think ACT first because of that :)
Thanks for the work on act tought, i love it

<!-- gh-comment-id:885161614 --> @Steph0 commented on GitHub (Jul 22, 2021): Hope the next release is soon with this. Have a hard time convincing my team to think ACT first because of that :) Thanks for the work on act tought, i love it
Author
Owner

@karisalonen commented on GitHub (Aug 3, 2021):

+1

<!-- gh-comment-id:891781623 --> @karisalonen commented on GitHub (Aug 3, 2021): +1
Author
Owner

@cplee commented on GitHub (Aug 3, 2021):

@Steph0 - just released https://github.com/nektos/act/releases/tag/v0.2.24

<!-- gh-comment-id:892046065 --> @cplee commented on GitHub (Aug 3, 2021): @Steph0 - just released https://github.com/nektos/act/releases/tag/v0.2.24
Author
Owner

@Steph0 commented on GitHub (Aug 6, 2021):

Love it thanks !

<!-- gh-comment-id:894182594 --> @Steph0 commented on GitHub (Aug 6, 2021): Love it thanks !
Author
Owner

@dirablue commented on GitHub (Sep 7, 2021):

When I run this example https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-8

name: Diff AccessDB
on: [pull_request]

jobs:
  job1:
    runs-on: ubuntu-latest
    # Map a step output to a job output
    outputs:
      output1: ${{ steps.step1.outputs.test }}
      output2: ${{ steps.step2.outputs.test }}
    steps:
      - id: step1
        run: echo "::set-output name=test::hello"
      - id: step2
        run: echo "::set-output name=test::world"
  job2:
    runs-on: ubuntu-latest
    needs: job1
    steps:
      - run: echo ${{needs.job1.outputs.output1}} ${{needs.job1.outputs.output2}}

Then I am getting this error in the latest @master version when I run act.

ERRO[0003] Unable to interpolate string '${{ steps.step2.outputs.test }}' - [TypeError: Cannot access member 'outputs' of undefined]

Is this a known limitation?

@cplee
hi, is there any update on this.. ?

<!-- gh-comment-id:914231607 --> @dirablue commented on GitHub (Sep 7, 2021): > When I run this example https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-8 > > ```yaml > name: Diff AccessDB > on: [pull_request] > > jobs: > job1: > runs-on: ubuntu-latest > # Map a step output to a job output > outputs: > output1: ${{ steps.step1.outputs.test }} > output2: ${{ steps.step2.outputs.test }} > steps: > - id: step1 > run: echo "::set-output name=test::hello" > - id: step2 > run: echo "::set-output name=test::world" > job2: > runs-on: ubuntu-latest > needs: job1 > steps: > - run: echo ${{needs.job1.outputs.output1}} ${{needs.job1.outputs.output2}} > ``` > > Then I am getting this error in the latest `@master` version when I run act. > > > ERRO[0003] Unable to interpolate string '${{ steps.step2.outputs.test }}' - [TypeError: Cannot access member 'outputs' of undefined] > > Is this a known limitation? @cplee hi, is there any update on this.. ?
Author
Owner

@catthehacker commented on GitHub (Sep 7, 2021):

No

<!-- gh-comment-id:914249200 --> @catthehacker commented on GitHub (Sep 7, 2021): No
Author
Owner

@littleamigo commented on GitHub (Nov 19, 2021):

I have tried your test workflow from https://github.com/nektos/act/pull/629 > pkg/model/workflow_test.go and it works :)

[test/test2] ⭐  Run test2_1
| some-a_value
| some-b-value
[test/test2]   ✅  Success - test2_1

Then I inserted a single step 'doSomething' before the step with the output assignments and it failed, i.e. all output variables are empty :(

jobs:
  test1:
    runs-on: ubuntu-latest
    steps:
      - id: doSomething
        run: echo "do something..."
      - id: test1_1
        run: |
          echo "::set-output name=a_key::some-a_value"
          echo "::set-output name=b-key::some-b-value"
    outputs:
      some_a_key: ${{ steps.test1_1.outputs.a_key }}
      some-b-key: ${{ steps.test1_1.outputs.b-key }}
  test2:
    runs-on: ubuntu-latest
    needs:
      - test1
    steps:
      - name: test2_1
        run: |
          echo "${{ needs.test1.outputs.some_a_key }}"
          echo "${{ needs.test1.outputs.some-b-key }}"
[test/test2] ⭐  Run test2_1
workflow-test/workflow/0] user=
|
|
[test/test2]   ✅  Success - test2_1

Can this bug be fixed soon?

<!-- gh-comment-id:973990389 --> @littleamigo commented on GitHub (Nov 19, 2021): I have tried your test workflow from https://github.com/nektos/act/pull/629 > pkg/model/workflow_test.go and it works :) ``` [test/test2] ⭐ Run test2_1 | some-a_value | some-b-value [test/test2] ✅ Success - test2_1 ``` Then I inserted a single step '**doSomething**' before the step with the output assignments and it failed, i.e. all output variables are empty :( ``` jobs: test1: runs-on: ubuntu-latest steps: - id: doSomething run: echo "do something..." - id: test1_1 run: | echo "::set-output name=a_key::some-a_value" echo "::set-output name=b-key::some-b-value" outputs: some_a_key: ${{ steps.test1_1.outputs.a_key }} some-b-key: ${{ steps.test1_1.outputs.b-key }} test2: runs-on: ubuntu-latest needs: - test1 steps: - name: test2_1 run: | echo "${{ needs.test1.outputs.some_a_key }}" echo "${{ needs.test1.outputs.some-b-key }}" ``` ``` [test/test2] ⭐ Run test2_1 workflow-test/workflow/0] user= | | [test/test2] ✅ Success - test2_1 ``` Can this bug be fixed soon?
Author
Owner

@nomadme commented on GitHub (Jan 4, 2022):

Same problem, still getting empty output variables from step.

act version 0.2.25

<!-- gh-comment-id:1004550346 --> @nomadme commented on GitHub (Jan 4, 2022): Same problem, still getting empty output variables from step. `act version 0.2.25`
Author
Owner

@ZauberNerd commented on GitHub (Feb 1, 2022):

As far as I can see, all the example workflows posted here work fine with 0.2.25.

@littleamigo that sounds like: https://github.com/nektos/act/issues/758 which has been fixed in 0.2.25 (see the release notes: https://github.com/nektos/act/releases/tag/v0.2.25 and note commit ff8b1df).

<!-- gh-comment-id:1027158666 --> @ZauberNerd commented on GitHub (Feb 1, 2022): As far as I can see, all the example workflows posted here work fine with `0.2.25`. @littleamigo that sounds like: https://github.com/nektos/act/issues/758 which has been fixed in `0.2.25` (see the release notes: https://github.com/nektos/act/releases/tag/v0.2.25 and note commit ff8b1df).
Author
Owner

@Bouncner commented on GitHub (Feb 21, 2022):

Still facing this issue with [TypeError: Cannot access member 'outputs' of undefined] and version 0.2.25. On GitHub, the workflow runs just fine.

<!-- gh-comment-id:1047217950 --> @Bouncner commented on GitHub (Feb 21, 2022): Still facing this issue with `[TypeError: Cannot access member 'outputs' of undefined]` and version 0.2.25. On GitHub, the workflow runs just fine.
Author
Owner

@ZauberNerd commented on GitHub (Feb 22, 2022):

@Bouncner please provide us with a minimal reproducible workflow.

<!-- gh-comment-id:1047551444 --> @ZauberNerd commented on GitHub (Feb 22, 2022): @Bouncner please provide us with a minimal reproducible workflow.
Author
Owner

@Bouncner commented on GitHub (Feb 22, 2022):

I tried, but I am not able to reproduce it without the large setup. Interestingly, it happens in the step after the step that sets the output.

id: core_client_counts sets the outputs and then act crashes with:

| FAILED: hyrise/src/lib/CMakeFiles/resourceLink
| cd /home/User/encoding_selection/encoding_plugin/rel/hyrise/src/lib && ln -fs /home/User/encoding_selection/encoding_plugin/rel/../resources /home/User/encoding_selection/encoding_plugin/rel/
| ln: /home/User/encoding_selection/encoding_plugin/rel/resources: cannot overwrite directory
[3/8] cd /home/User/encoding_selection/encoding_plugin/rel/hyrise/src/lib && /usr/bin/cmake -DGIT_FUNCTION=DoMonitoring -DGIT_WORKING_DIR=/home/User/encoding_selection/encoding_plugin/hyrise/src/lib -Dpre_configure_file=/home/User/encoding_selection/encoding_plugin/hyrise/src/lib/version.hpp.in -Dpost_configure_file=/home/User/encoding_selection/encoding_plugin/rel/version.hpp -P /home/User/encoding_selection/encoding_plugin/hyrise/cmake/git_watcher.cmake
| ninja: build stopped: subcommand failed.
[Main/Hyrise - Full calibration and evaluation pipeline]   ❌  Failure - Build release server and plugins
ERRO[0205] Unable to interpolate string '${{ steps.calibration.outputs.calibration_run }}' - [TypeError: Cannot access member 'outputs' of undefined]
Error: exit with `FAILURE`: 1

This is during the compilation, which is the step after the output setting.

github.com/hyrise/encoding_selection@9c5d3082ef/.github/workflows/haupt.yml (L69)

<!-- gh-comment-id:1047877613 --> @Bouncner commented on GitHub (Feb 22, 2022): I tried, but I am not able to reproduce it without the large setup. Interestingly, it happens in the **step after the step that sets the output**. `id: core_client_counts` sets the outputs and then act crashes with: ``` | FAILED: hyrise/src/lib/CMakeFiles/resourceLink | cd /home/User/encoding_selection/encoding_plugin/rel/hyrise/src/lib && ln -fs /home/User/encoding_selection/encoding_plugin/rel/../resources /home/User/encoding_selection/encoding_plugin/rel/ | ln: /home/User/encoding_selection/encoding_plugin/rel/resources: cannot overwrite directory [3/8] cd /home/User/encoding_selection/encoding_plugin/rel/hyrise/src/lib && /usr/bin/cmake -DGIT_FUNCTION=DoMonitoring -DGIT_WORKING_DIR=/home/User/encoding_selection/encoding_plugin/hyrise/src/lib -Dpre_configure_file=/home/User/encoding_selection/encoding_plugin/hyrise/src/lib/version.hpp.in -Dpost_configure_file=/home/User/encoding_selection/encoding_plugin/rel/version.hpp -P /home/User/encoding_selection/encoding_plugin/hyrise/cmake/git_watcher.cmake | ninja: build stopped: subcommand failed. [Main/Hyrise - Full calibration and evaluation pipeline] ❌ Failure - Build release server and plugins ERRO[0205] Unable to interpolate string '${{ steps.calibration.outputs.calibration_run }}' - [TypeError: Cannot access member 'outputs' of undefined] Error: exit with `FAILURE`: 1 ``` This is during the compilation, which is the step after the output setting. https://github.com/hyrise/encoding_selection/blob/9c5d3082efd444aa6f12091793d2bdb289d695ef/.github/workflows/haupt.yml#L69
Author
Owner

@ZauberNerd commented on GitHub (Feb 23, 2022):

@Bouncner this seems to be an aftereffect of a previous step failing. You can see in your output above that the Build release server and plugins step failed - fix this and the outputs should work.

You're also correct, that here the behaviour of act differs from GitHub Actions, but once you fix the above error it should work.

Here's an example workflow that illustrates the problem:

on: push
jobs:
  job1:
    runs-on: ubuntu-latest
    outputs:
      output1: ${{ steps.step1.outputs.test }}
      output2: ${{ steps.step2.outputs.test }}
    steps:
      - id: step1
        run: echo "::set-output name=test::hello"
      - run: exit 1 # removing this line makes the workflow succeed
      - id: step2
        run: echo "::set-output name=test::world"
<!-- gh-comment-id:1048674617 --> @ZauberNerd commented on GitHub (Feb 23, 2022): @Bouncner this seems to be **an aftereffect of a previous step failing**. You can see in your output above that the `Build release server and plugins` step failed - fix this and the outputs should work. You're also correct, that here the behaviour of act differs from GitHub Actions, but once you fix the above error it should work. Here's an example workflow that illustrates the problem: ``` on: push jobs: job1: runs-on: ubuntu-latest outputs: output1: ${{ steps.step1.outputs.test }} output2: ${{ steps.step2.outputs.test }} steps: - id: step1 run: echo "::set-output name=test::hello" - run: exit 1 # removing this line makes the workflow succeed - id: step2 run: echo "::set-output name=test::world" ```
Author
Owner

@Bouncner commented on GitHub (Feb 23, 2022):

Argh, been blind. I reused the setup and didn't realize that this caused the compilation error. Sorry.

If I had a which, an more telling error message would be awesome.

<!-- gh-comment-id:1048948750 --> @Bouncner commented on GitHub (Feb 23, 2022): Argh, been blind. I reused the setup and didn't realize that this caused the compilation error. Sorry. If I had a which, an more telling error message would be awesome.
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#206
No description provided.