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

fix: unset YARN_IGNORE_PATH before calling yarn in @nodejs targets #1589

Merged
merged 2 commits into from
Feb 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
13 changes: 11 additions & 2 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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,
Expand All @@ -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"),
Expand All @@ -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%
Expand Down
2 changes: 1 addition & 1 deletion internal/npm_install/npm_install.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down