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

Set YARN_IGNORE_PATH=1 #15

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,7 @@ if %errorlevel% neq 0 exit /b %errorlevel%

# 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.
# Set YARN_IGNORE_PATH=1 so it doesn't go throug our .yarn/releases/yarn.sh wrapper
christianscott marked this conversation as resolved.
Show resolved Hide resolved
if not is_windows:
# Yarn entry point
repository_ctx.file(
Expand All @@ -604,7 +600,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
export YARN_IGNORE_PATH=1
{get_script_dir}
"$SCRIPT_DIR/{node}" "$SCRIPT_DIR/{script}" "$@"
""".format(
Expand All @@ -624,7 +620,7 @@ set -e
""" + GET_SCRIPT_DIR + "".join([
"""
echo Running yarn "$@" in {root}
unset YARN_IGNORE_PATH
export YARN_IGNORE_PATH=1
(cd "{root}"; "$SCRIPT_DIR/{node}" "$SCRIPT_DIR/{script}" "$@")
""".format(
root = repository_ctx.path(package_json).dirname,
Expand All @@ -639,7 +635,7 @@ unset YARN_IGNORE_PATH
"bin/yarn.cmd",
content = """@echo off
SET SCRIPT_DIR=%~dp0
SET "YARN_IGNORE_PATH="
SET "YARN_IGNORE_PATH=1"
"%SCRIPT_DIR%\\{node}" "%SCRIPT_DIR%\\{script}" %*
""".format(
node = paths.relativize(node_entry, "bin"),
Expand All @@ -654,7 +650,7 @@ SET SCRIPT_DIR=%~dp0
""" + "".join([
"""
echo Running yarn %* in {root}
SET "YARN_IGNORE_PATH="
SET "YARN_IGNORE_PATH=1"
cd /D "{root}"
CALL "%SCRIPT_DIR%\\{node}" "%SCRIPT_DIR%\\{script}" %*
if %errorlevel% neq 0 exit /b %errorlevel%
Expand Down
10 changes: 3 additions & 7 deletions internal/npm_install/npm_install.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -743,17 +743,13 @@ 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.
# 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.
# Set YARN_IGNORE_PATH=1 so it doesn't go throug our .yarn/releases/yarn.sh wrapper
christianscott marked this conversation as resolved.
Show resolved Hide resolved
repository_ctx.file(
"_yarn.sh",
content = """#!/usr/bin/env bash
# Immediately exit if any command fails.
set -e
unset YARN_IGNORE_PATH
export YARN_IGNORE_PATH=1
(cd "{root}"; "{yarn}" {yarn_args})
""".format(
root = root,
Expand All @@ -766,7 +762,7 @@ unset YARN_IGNORE_PATH
repository_ctx.file(
"_yarn.cmd",
content = """@echo off
set "YARN_IGNORE_PATH="
set "YARN_IGNORE_PATH=1"
cd /D "{root}" && "{yarn}" {yarn_args}
""".format(
root = root,
Expand Down