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

[Bug]: @yarnpkg/shell doesn't support clearing env variables #4447

Closed
1 task
SubJunk opened this issue May 11, 2022 · 2 comments · Fixed by #6430
Closed
1 task

[Bug]: @yarnpkg/shell doesn't support clearing env variables #4447

SubJunk opened this issue May 11, 2022 · 2 comments · Fixed by #6430
Labels
bug Something isn't working reproducible This issue can be successfully reproduced shell This issue is about @yarnpkg/shell

Comments

@SubJunk
Copy link

SubJunk commented May 11, 2022

Self-service

  • I'd be willing to implement a fix

Describe the bug

I am in the process of migrating Yarn from v1 to latest (v3.2.0) and it has gone well, but now my tests don't run because the test script unsets some environment variables.

The output is:

command not found: unset

To reproduce

await packageJsonAndInstall({
	scripts: {
		myscript: 'unset AN_ENV_VAR && env',
		test: 'AN_ENV_VAR=foo run myscript',
	},
});

await expect(yarn(`test`)).resolves.not.toContain(`AN_ENV_VAR`);

Environment

yarn run v1.22.17
error Command "dlx" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Additional context

No response

@SubJunk SubJunk added the bug Something isn't working label May 11, 2022
@yarnbot

This comment has been minimized.

@yarnbot yarnbot added the stale Issues that didn't get attention label Jun 10, 2022
@merceyz merceyz changed the title [Bug?]: Regression from v1: Unsetting environment variables in package.json [Bug]: @yarnpkg/shell doesn't support unset Jun 10, 2022
@merceyz merceyz changed the title [Bug]: @yarnpkg/shell doesn't support unset [Bug]: @yarnpkg/shell doesn't support clearing env variables Jun 10, 2022
@yarnbot yarnbot added the reproducible This issue can be successfully reproduced label Jun 10, 2022
@yarnbot
Copy link
Collaborator

yarnbot commented Jun 10, 2022

This issue reproduces on master:

Error: expect(received).resolves.not.toContain()

Received promise rejected instead of resolved
Rejected to value: [Error: Command failed: /usr/bin/node /github/workspace/scripts/actions/../run-yarn.js test
command not found: unset

]
    at expect (/github/workspace/.yarn/cache/expect-npm-24.8.0-8c7640c562-44ff9ab1e7.zip/node_modules/expect/build/index.js:138:15)
    at module.exports (evalmachine.<anonymous>:9:7)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-286d94b96d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:57:13
    at async executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-286d94b96d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:18:16)
    at async executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-286d94b96d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:25:12)
    at async ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-286d94b96d.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:26:38)
    at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-4061026d74.zip/node_modules/clipanion/lib/advanced/Command.js:161:26)
    at async Cli.run (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-4061026d74.zip/node_modules/clipanion/lib/advanced/Cli.js:74:24)
    at async Cli.runExit (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-4061026d74.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)

@merceyz merceyz removed the stale Issues that didn't get attention label Jun 10, 2022
@paul-soporan paul-soporan added the shell This issue is about @yarnpkg/shell label Sep 16, 2022
github-merge-queue bot pushed a commit that referenced this issue Aug 25, 2024
## What's the problem this PR addresses?

<!-- Describe the rationale of your PR. -->
<!-- Link all issues that it closes. (Closes/Resolves #xxxx.) -->

Fixes #4447.

## How did you fix it?

<!-- A detailed description of your implementation. -->

I fixed it by adding an `unset` built-in.

## Checklist

<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [x] I have set the packages that need to be released for my changes to
be effective.

<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.

---------

Co-authored-by: merceyz <merceyz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproducible This issue can be successfully reproduced shell This issue is about @yarnpkg/shell
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants