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

How to target setup NODE version using environmental variables without hitting runner itself? #356

Closed
2 of 5 tasks
jkabat opened this issue Nov 4, 2021 · 3 comments
Closed
2 of 5 tasks
Assignees
Labels
bug Something isn't working

Comments

@jkabat
Copy link

jkabat commented Nov 4, 2021

Description:
Im trying to add Node v17 into the matrix but because of known openssl bug I need to set "--openssl-legacy-provider" in NODE_OPTIONS. Using actions environment variables seems to be affected even runner which is not very recent and fails on unrecognizable option. Is there something I can do about it?

Action version:
Latest.

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:

  - name: Setup NODE
    uses: actions/setup-node@v1
    with:
          node-version: "17"
    env:
          NODE_OPTIONS: "--openssl-legacy-provider"

Expected behavior:
Step will end up without an error.

Actual behavior:
Step fails with:

Run actions/setup-node@v2.4.1
/home/runner/runners/2.283.3/externals/node12/bin/node: --openssl-legacy-provider is not allowed in NODE_OPTIONS```
@jkabat jkabat added bug Something isn't working needs triage labels Nov 4, 2021
@mjubilee1
Copy link

@jkabat Any follow up on this issue? I'm also trying to setup Node 17.

@dmitry-shibanov
Copy link
Contributor

Hello everyone. You've got an issue, because initially default node.js version is 12 for actions, that is why it does not accept such flag. If you need this options global for all steps, you can add global environment variable after installation of node.js. You can try to use this snippet:

      - name: Setup NODE
        uses: actions/setup-node@v2
        with:
          node-version: "17"
      - run: echo 'NODE_OPTIONS="--openssl-legacy-provider"' >> $GITHUB_ENV

Besides, you can use it only for specific steps by this:

      - name: Setup NODE
        uses: actions/setup-node@v2
        with:
          node-version: "17"
      - run: node --version
        env:
          NODE_OPTIONS: "--openssl-legacy-provider"

Moreover, the most actions in actions' organisation use node12 as default one, that is why I think it's better to use NODE_OPTIONS for specific steps.

@jkabat
Copy link
Author

jkabat commented Nov 9, 2021

@dmitry-shibanov thanks for the hint.

Resolved using additional step:

            - name: Override NODE options for the most recent version
              if: matrix.node-version == '17'
              run: echo "NODE_OPTIONS=--openssl-legacy-provider" >> $GITHUB_ENV

Do not forget to restore original options if you depend on other runner actions (like cache POST job).

@jkabat jkabat closed this as completed Nov 9, 2021
deining pushed a commit to deining/setup-node that referenced this issue Nov 9, 2023
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Andreas61129 added a commit to linkit-tech/signature-generator that referenced this issue Apr 6, 2024
Adjust environment variable NODE_OPTIONS for linux.

Otherwise the main.yml file has to be changed according to actions/setup-node#356.
Andreas61129 added a commit to linkit-tech/signature-generator that referenced this issue Apr 6, 2024
Add NODE_OPTIONS according to actions/setup-node#356 for the specific step of the workflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants