diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 075c916029..6a02533ddd 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -6,6 +6,7 @@ tasks: platform: ubuntu1604 run_targets: - "@nodejs//:yarn_node_repositories" + - "@nodejs//:yarn" # Regression test for #1493 - "//packages/create:npm_package.pack" - "//internal/node/test:no_deps" @@ -103,6 +104,7 @@ tasks: platform: ubuntu1804 run_targets: - "@nodejs//:yarn_node_repositories" + - "@nodejs//:yarn" - "//internal/node/test:no_deps" - "//internal/node/test:has_deps_legacy" - "//internal/node/test:has_deps" @@ -243,6 +245,7 @@ tasks: platform: macos run_targets: - "@nodejs//:yarn_node_repositories" + - "@nodejs//:yarn" # Regression test for #1493 - "//packages/create:npm_package.pack" - "//internal/node/test:no_deps" @@ -354,6 +357,7 @@ tasks: platform: windows run_targets: - "@nodejs//:yarn_node_repositories" + - "@nodejs//:yarn" - "//internal/node/test:no_deps" - "//internal/node/test:has_deps_legacy" - "//internal/node/test:has_deps" diff --git a/internal/node/node_repositories.bzl b/internal/node/node_repositories.bzl index f68210a507..b751d0425f 100644 --- a/internal/node/node_repositories.bzl +++ b/internal/node/node_repositories.bzl @@ -529,8 +529,13 @@ if %errorlevel% neq 0 exit /b %errorlevel% script = repository_ctx.path(npm_script), )) - # The entry points for yarn for osx/linux and windows - # Runs yarn using appropriate node entry point + # The entry points for yarn for osx/linux and windows. + # Runs yarn using appropriate node entry point. + # 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. if not is_windows: # Yarn entry point repository_ctx.file( @@ -539,6 +544,7 @@ if %errorlevel% neq 0 exit /b %errorlevel% # Generated by node_repositories.bzl # Immediately exit if any command fails. set -e +unset YARN_IGNORE_PATH {get_script_dir} "$SCRIPT_DIR/{node}" "$SCRIPT_DIR/{script}" "$@" """.format( @@ -558,6 +564,7 @@ set -e """ + GET_SCRIPT_DIR + "".join([ """ echo Running yarn "$@" in {root} +unset YARN_IGNORE_PATH (cd "{root}"; "$SCRIPT_DIR/{node}" "$SCRIPT_DIR/{script}" "$@") """.format( root = repository_ctx.path(package_json).dirname, @@ -572,6 +579,7 @@ echo Running yarn "$@" in {root} "bin/yarn.cmd", content = """@echo off SET SCRIPT_DIR=%~dp0 +SET "YARN_IGNORE_PATH=" "%SCRIPT_DIR%\\{node}" "%SCRIPT_DIR%\\{script}" %* """.format( node = paths.relativize(node_entry, "bin"), @@ -586,6 +594,7 @@ SET SCRIPT_DIR=%~dp0 """ + "".join([ """ echo Running yarn %* in {root} +SET "YARN_IGNORE_PATH=" cd "{root}" CALL "%SCRIPT_DIR%\\{node}" "%SCRIPT_DIR%\\{script}" %* if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/internal/npm_install/npm_install.bzl b/internal/npm_install/npm_install.bzl index 611e11cbb9..55d5afbe9e 100644 --- a/internal/npm_install/npm_install.bzl +++ b/internal/npm_install/npm_install.bzl @@ -363,7 +363,7 @@ unset YARN_IGNORE_PATH repository_ctx.file( "_yarn.cmd", content = """@echo off -set "YARN_IGNORE_PATH=" +set "YARN_IGNORE_PATH=" cd "{root}" && "{yarn}" {yarn_args} """.format( root = root,