diff --git a/internal/npm_install/npm_install.bzl b/internal/npm_install/npm_install.bzl index 037bf479e3..611e11cbb9 100644 --- a/internal/npm_install/npm_install.bzl +++ b/internal/npm_install/npm_install.bzl @@ -339,12 +339,18 @@ def _yarn_install_impl(repository_ctx): # The entry points for npm install for osx/linux and windows if not is_windows_host: - # Prefix filenames with _ so they don't conflict with the npm packages + # Prefix filenames with _ so they don't conflict with the npm packages. + # Unset YARN_IGNORE_PATH before calling yarn incase it is set so that + # .yarnrc yarn-path is followed if set. This is for the case when calling + # bazel from yarn with `yarn bazel ...` and yarn follows yarn-path in + # .yarnrc it will set YARN_IGNORE_PATH=1 which will prevent the bazel + # call into yarn from also following the yarn-path as desired. repository_ctx.file( "_yarn.sh", content = """#!/usr/bin/env bash # Immediately exit if any command fails. set -e +unset YARN_IGNORE_PATH (cd "{root}"; "{yarn}" {yarn_args}) """.format( root = root, @@ -357,6 +363,7 @@ set -e repository_ctx.file( "_yarn.cmd", content = """@echo off +set "YARN_IGNORE_PATH=" cd "{root}" && "{yarn}" {yarn_args} """.format( root = root,