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

Remove deprecated preserve_symlinks option. #763

Closed
Closed
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
1 change: 0 additions & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ internal/e2e/fine_grained_deps/npm/node_modules
internal/e2e/fine_grained_deps/yarn/node_modules
internal/e2e/fine_grained_no_bin/node_modules
internal/e2e/fine_grained_symlinks
internal/e2e/node_loader_no_preserve_symlinks
internal/e2e/node_loader_preserve_symlinks
internal/e2e/packages
1 change: 0 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ node_repositories(
"@examples_program//:package.json",
"//internal/npm_install/test:package/package.json",
],
preserve_symlinks = True,
)

yarn_install(
Expand Down
1 change: 0 additions & 1 deletion internal/e2e/node_loader_no_preserve_symlinks/.bazelignore

This file was deleted.

1 change: 0 additions & 1 deletion internal/e2e/node_loader_no_preserve_symlinks/.bazelrc

This file was deleted.

11 changes: 0 additions & 11 deletions internal/e2e/node_loader_no_preserve_symlinks/BUILD.bazel

This file was deleted.

21 changes: 0 additions & 21 deletions internal/e2e/node_loader_no_preserve_symlinks/WORKSPACE

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions internal/e2e/node_loader_no_preserve_symlinks/package.json

This file was deleted.

123 changes: 0 additions & 123 deletions internal/e2e/node_loader_no_preserve_symlinks/yarn.lock

This file was deleted.

1 change: 0 additions & 1 deletion internal/node/generate_build_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ function generateBuildFile() {
package(default_visibility = ["//visibility:public"])
exports_files([
"run_npm.sh.template",
"bin/node_args.sh",
"${NODE_DIR}/bin/node",
"bin/node${binaryExt}",
"bin/npm${binaryExt}",
Expand Down
7 changes: 1 addition & 6 deletions internal/node/node.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def _nodejs_binary_impl(ctx):
"TEMPLATED_env_vars": env_vars,
"TEMPLATED_expected_exit_code": str(expected_exit_code),
"TEMPLATED_node": _short_path_to_manifest_path(ctx, node.short_path),
"TEMPLATED_repository_args": _short_path_to_manifest_path(ctx, ctx.file._repository_args.short_path),
"TEMPLATED_script_path": script_path,
}
ctx.actions.expand_template(
Expand All @@ -169,7 +168,7 @@ def _nodejs_binary_impl(ctx):
is_executable = True,
)

runfiles = depset([node, ctx.outputs.loader, ctx.file._repository_args] + ctx.files._node_runfiles, transitive = [sources, node_modules])
runfiles = depset([node, ctx.outputs.loader] + ctx.files._node_runfiles, transitive = [sources, node_modules])

return [DefaultInfo(
executable = ctx.outputs.script,
Expand Down Expand Up @@ -312,10 +311,6 @@ _NODEJS_EXECUTABLE_ATTRS = {
default = Label("@nodejs//:node_runfiles"),
allow_files = True,
),
"_repository_args": attr.label(
default = Label("@nodejs//:bin/node_args.sh"),
allow_single_file = True,
),
"_source_map_support_files": attr.label_list(
default = [
Label("//third_party/github.com/buffer-from:contents"),
Expand Down
6 changes: 2 additions & 4 deletions internal/node/node_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,12 @@ TEMPLATED_env_vars
# find . -name thingImLookingFor 1>&2

readonly node=$(rlocation "TEMPLATED_node")
readonly repository_args=$(rlocation "TEMPLATED_repository_args")
readonly script=$(rlocation "TEMPLATED_script_path")

source $repository_args

ARGS=()
NODE_OPTIONS=()
ALL_ARGS=(TEMPLATED_args $NODE_REPOSITORY_ARGS "$@")
# TODO: Add --preserve-symlinks-main as well for node >= 10.2.0
ALL_ARGS=(TEMPLATED_args --node_options=--preserve-symlinks "$@")
for ARG in "${ALL_ARGS[@]}"; do
case "$ARG" in
--node_options=*) NODE_OPTIONS+=( "${ARG#--node_options=}" ) ;;
Expand Down
25 changes: 1 addition & 24 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ def _prepare_node(repository_ctx):
npm_script_relative = npm_script if repository_ctx.attr.vendored_node else paths.relativize(npm_script, "bin")
yarn_script_relative = yarn_script if repository_ctx.attr.vendored_yarn else paths.relativize(yarn_script, "bin")

if not repository_ctx.attr.preserve_symlinks:
print("\nWARNING: The preserve_symlinks option is deprecated and will go away in the future.\n")

# The entry points for node for osx/linux and windows
if not is_windows:
# Sets PATH and runs the application
Expand All @@ -250,16 +247,6 @@ SET PATH=%SCRIPT_DIR%;%PATH%
CALL "%SCRIPT_DIR%\\{node}" %*
""".format(node = node_exec_relative))

# Shell script to set repository arguments for node used by nodejs_binary & nodejs_test launcher
# TODO(gregmagolan): add --node_options=--preserve-symlinks-main as well if preserve_symlinks is True &
# node version >= 10.2.0
repository_ctx.file("bin/node_args.sh", content = """#!/usr/bin/env bash
# Immediately exit if any command fails.
set -e
# Generated by node_repositories.bzl
export NODE_REPOSITORY_ARGS={}
""".format("--node_options=--preserve-symlinks" if repository_ctx.attr.preserve_symlinks else ""), executable = True)

# The entry points for npm for osx/linux and windows
# Runs npm using appropriate node entry point
# --scripts-prepend-node-path is set to false since the correct paths
Expand Down Expand Up @@ -437,7 +424,6 @@ _nodejs_repo = repository_rule(
# Options to override node version
"node_version": attr.string(default = DEFAULT_NODE_VERSION),
"package_json": attr.label_list(),
"preserve_symlinks": attr.bool(default = True),
"vendored_node": attr.label(allow_single_file = True),
"vendored_yarn": attr.label(allow_single_file = True),
"yarn_repositories": attr.string_list_dict(default = YARN_REPOSITORIES),
Expand Down Expand Up @@ -467,8 +453,7 @@ def node_repositories(
node_repositories = NODE_REPOSITORIES,
yarn_repositories = YARN_REPOSITORIES,
node_urls = NODE_URLS,
yarn_urls = YARN_URLS,
preserve_symlinks = True):
yarn_urls = YARN_URLS):
"""To be run in user's WORKSPACE to install rules_nodejs dependencies.

This rule sets up node, npm, and yarn.
Expand Down Expand Up @@ -523,13 +508,6 @@ def node_repositories(
yarn_repositories: optional; custom list of yarn repositories to use.
node_urls: optional; custom list of URLs to use to download NodeJS.
yarn_urls: optional; custom list of URLs to use to download Yarn.
preserve_symlinks: Turn on --node_options=--preserve-symlinks for nodejs_binary and nodejs_test rules.
The default for this is currently True but the options is deprecated and will be removed in the future.
When this option is turned on, node will preserve the symlinked path for resolves instead of the default
behavior of resolving to the real path. This means that all required files must be in be included in your
runfiles as it prevents the default behavior of potentially resolving outside of the runfiles. For example,
all required files need to be included in your node_modules filegroup. This option is desirable as it gives
a stronger guarantee of hermiticity which is required for remote execution.
"""

# 0.14.0: @bazel_tools//tools/bash/runfiles is required for nodejs
Expand All @@ -550,7 +528,6 @@ def node_repositories(
yarn_repositories = yarn_repositories,
node_urls = node_urls,
yarn_urls = yarn_urls,
preserve_symlinks = preserve_symlinks,
)

_maybe(
Expand Down