Skip to content

[Bug?]: YARN_IGNORE_SCRIPTS environment variable shouldn't result in an error #7117

@tbroyer

Description

@tbroyer

Self-service

  • I'd be willing to implement a fix

Describe the bug

In an effort to harden our CI (the Axios incident was the final straw), we've added the following environment variables to disable all postinstall scripts (even if it possibly does more than just that, particularly with NPM), overriding any project-local configuration:

# For NPM
npm_config_ignore_scripts=true
# For Yarn Classic
YARN_IGNORE_SCRIPTS=true
# For Yarn Modern
YARN_ENABLE_SCRIPTS=false

This however broke all the builds that use Yarn Modern:

Usage Error: Unrecognized or legacy configuration settings found: ignoreScripts - run "yarn config" to see the list of settings supported in Yarn (in <environment>)

IGNORED_ENV_VARIABLES at https://github.com/yarnpkg/berry/blob/%40yarnpkg/cli/4.14.1/packages/yarnpkg-core/sources/Configuration.ts#L67 should probably include ignoreScripts in the same way it ignores YARN_REGISTRY.

To reproduce

$ docker run --rm \
      -e npm_config_ignore_scripts=true -e YARN_IGNORE_SCRIPTS=true -e YARN_ENABLE_SCRIPTS=false \
      node:lts-slim \
      corepack yarn@latest --version
4.14.1
$ docker run --rm \
    -e npm_config_ignore_scripts=true -e YARN_IGNORE_SCRIPTS=true -e YARN_ENABLE_SCRIPTS=false \
    node:lts-slim \
    corepack yarn@latest dlx -q envinfo --preset jest
Usage Error: Unrecognized or legacy configuration settings found: ignoreScripts - run "yarn config" to see the list of settings supported in Yarn (in <environment>)

$ yarn add [--json] [-F,--fixed] [-E,--exact] [-T,--tilde] [-C,--caret] [-D,--dev] [-P,--peer] [-O,--optional] [--prefer-dev] [-i,--interactive] [--cached] [--mode #0] ...

Environment

System:
    OS: Linux 6.19 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 24.15.0 - /tmp/xfs-b749a6f7/node
    Yarn: 1.22.22 - /tmp/xfs-b749a6f7/yarn
    npm: 11.12.1 - /usr/local/bin/npm

Additional context

As a workaround, I found the undocumented YARN_ENABLE_STRICT_SETTINGS:

$ docker run --rm \
      -e npm_config_ignore_scripts=true -e YARN_IGNORE_SCRIPTS=true -e YARN_ENABLE_SCRIPTS=false \
      -e YARN_ENABLE_STRICT_SETTINGS=false \
      node:lts-slim \
      corepack yarn@latest --version
4.14.1
$ docker run --rm \
      -e npm_config_ignore_scripts=true -e YARN_IGNORE_SCRIPTS=true -e YARN_ENABLE_SCRIPTS=false \
      -e YARN_ENABLE_STRICT_SETTINGS=false \
      node:lts-slim \
      corepack yarn@latest dlx -q envinfo --preset jest

  System:
    OS: Linux 6.19 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 24.15.0 - /tmp/xfs-b749a6f7/node
    Yarn: 1.22.22 - /tmp/xfs-b749a6f7/yarn
    npm: 11.12.1 - /usr/local/bin/npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions