actions / actions/toolkit

@core/exec: when you pass the `env` parameter to `exec.exec` it creates an empty env

Open
#1,158 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

When passing the env parameter to exec.exec or exec.getExecOutput the spawned process will have exactly only the env variables that are in the parameter and nothing else.

This is often not what a user wants. Many other env vars that are included by default (in case the env parameter isn't present) are needed for some commands to run.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Javacript action with the following code:
      const installResult = await exec.getExecOutput(
        'brew',
        ['install', 'docker'],
        {
          env: { HOMEBREW_NO_AUTO_UPDATE: '1' },
        },
      )
  1. Try to run it on a macOS runner.
  2. You will see broken terminal output and it won't work.

Removing that env parameter makes it all work, because all the other env vars that come by default are needed.

Expected behavior

I want to be able to add env vars to exec calls.

I believe the ability to specify a clean env (like it works now) is still valuable for some use cases, so these two should exist independently.

Additional context

Temporary workaround is to use something like:

{ env: { HOMEBREW_NO_AUTO_UPDATE: '1', ...process.env } }

I am not sure though whether it would work for everyone.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the exec.exec and exec.getExecOutput entry points named in the report, focusing on how their env parameter is passed to the spawned process. Confirm the current behavior with the macOS brew example or an equivalent environment-sensitive command. Done means callers can add variables while preserving the existing environment, while a separate clean-environment behavior remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.