Skip to content

Commit aee3003

Browse files
committed
fix: unset YARN_IGNORE_PATH before calling yarn in @nodejs targets
Same as #1588 but for the @nodejs//:yarn && @nodejs//:yarn_node_repositories targets. 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.
1 parent 39bb821 commit aee3003

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

internal/node/node_repositories.bzl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,13 @@ if %errorlevel% neq 0 exit /b %errorlevel%
529529
script = repository_ctx.path(npm_script),
530530
))
531531

532-
# The entry points for yarn for osx/linux and windows
533-
# Runs yarn using appropriate node entry point
532+
# The entry points for yarn for osx/linux and windows.
533+
# Runs yarn using appropriate node entry point.
534+
# Unset YARN_IGNORE_PATH before calling yarn incase it is set so that
535+
# .yarnrc yarn-path is followed if set. This is for the case when calling
536+
# bazel from yarn with `yarn bazel ...` and yarn follows yarn-path in
537+
# .yarnrc it will set YARN_IGNORE_PATH=1 which will prevent the bazel
538+
# call into yarn from also following the yarn-path as desired.
534539
if not is_windows:
535540
# Yarn entry point
536541
repository_ctx.file(
@@ -539,6 +544,7 @@ if %errorlevel% neq 0 exit /b %errorlevel%
539544
# Generated by node_repositories.bzl
540545
# Immediately exit if any command fails.
541546
set -e
547+
unset YARN_IGNORE_PATH
542548
{get_script_dir}
543549
"$SCRIPT_DIR/{node}" "$SCRIPT_DIR/{script}" "$@"
544550
""".format(
@@ -558,6 +564,7 @@ set -e
558564
""" + GET_SCRIPT_DIR + "".join([
559565
"""
560566
echo Running yarn "$@" in {root}
567+
unset YARN_IGNORE_PATH
561568
(cd "{root}"; "$SCRIPT_DIR/{node}" "$SCRIPT_DIR/{script}" "$@")
562569
""".format(
563570
root = repository_ctx.path(package_json).dirname,
@@ -572,6 +579,7 @@ echo Running yarn "$@" in {root}
572579
"bin/yarn.cmd",
573580
content = """@echo off
574581
SET SCRIPT_DIR=%~dp0
582+
SET "YARN_IGNORE_PATH="
575583
"%SCRIPT_DIR%\\{node}" "%SCRIPT_DIR%\\{script}" %*
576584
""".format(
577585
node = paths.relativize(node_entry, "bin"),
@@ -586,6 +594,7 @@ SET SCRIPT_DIR=%~dp0
586594
""" + "".join([
587595
"""
588596
echo Running yarn %* in {root}
597+
SET "YARN_IGNORE_PATH="
589598
cd "{root}"
590599
CALL "%SCRIPT_DIR%\\{node}" "%SCRIPT_DIR%\\{script}" %*
591600
if %errorlevel% neq 0 exit /b %errorlevel%

internal/npm_install/npm_install.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ unset YARN_IGNORE_PATH
363363
repository_ctx.file(
364364
"_yarn.cmd",
365365
content = """@echo off
366-
set "YARN_IGNORE_PATH="
366+
set "YARN_IGNORE_PATH="
367367
cd "{root}" && "{yarn}" {yarn_args}
368368
""".format(
369369
root = root,

0 commit comments

Comments
 (0)