6868# cat "$(rlocation my_workspace/path/to/my/data.txt)"
6969#
7070
71- if [[ ! -d " ${RUNFILES_DIR:-/ dev/ null} " && ! -f " ${RUNFILES_MANIFEST_FILE:-/ dev/ null} " ]]; then
72- if [[ -f " $0 .runfiles_manifest" ]]; then
73- export RUNFILES_MANIFEST_FILE=" $0 .runfiles_manifest"
74- elif [[ -f " $0 .runfiles/MANIFEST" ]]; then
75- export RUNFILES_MANIFEST_FILE=" $0 .runfiles/MANIFEST"
76- elif [[ -f " $0 .runfiles/build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash" ]]; then
77- export RUNFILES_DIR=" $0 .runfiles"
78- fi
79- fi
80-
8171case " $( uname -s | tr [:upper:] [:lower:]) " in
8272msys* |mingw* |cygwin* )
8373 # matches an absolute Windows path
8474 export _RLOCATION_ISABS_PATTERN=" ^[a-zA-Z]:[/\\ ]"
8575 ;;
8676* )
8777 # matches an absolute Unix path
88- export _RLOCATION_ISABS_PATTERN=" ^/[^/].*"
78+ # rules_nodejs modification
79+ # In the upstream this pattern requires a second character which is not a slash
80+ # https://github.com/bazelbuild/bazel/blob/22d376cf41d50bfee129a0a7fa656d66af2dbf14/tools/bash/runfiles/runfiles.bash#L88
81+ # However in integration testing with rules_docker we observe runfiles path starting with two slashes
82+ # This fails on Linux CI (not Mac or Windows) in our //e2e:e2e_nodejs_image:
83+ # ERROR[runfiles.bash]: cannot look up runfile "nodejs_linux_amd64/bin/nodejs/bin/node"
84+ # (RUNFILES_DIR="/app/main.runfiles/e2e_nodejs_image//app//main.runfiles", RUNFILES_MANIFEST_FILE="")
85+ export _RLOCATION_ISABS_PATTERN=" ^/.*"
8986 ;;
9087esac
9188
89+ if [[ ! -d " ${RUNFILES_DIR:-/ dev/ null} " && ! -f " ${RUNFILES_MANIFEST_FILE:-/ dev/ null} " ]]; then
90+ if [[ -f " $0 .runfiles_manifest" ]]; then
91+ export RUNFILES_MANIFEST_FILE=" $0 .runfiles_manifest"
92+ elif [[ -f " $0 .runfiles/MANIFEST" ]]; then
93+ export RUNFILES_MANIFEST_FILE=" $0 .runfiles/MANIFEST"
94+ elif [[ -f " $0 .runfiles/build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash" ]]; then
95+ if [[ " ${0} " =~ $_RLOCATION_ISABS_PATTERN ]]; then
96+ export RUNFILES_DIR=" ${0} .runfiles"
97+ else
98+ export RUNFILES_DIR=" ${PWD} /${0} .runfiles"
99+ fi
100+ fi
101+ fi
102+
92103# --- begin rules_nodejs custom code ---
93104# normpath() function removes all `/./` and `dir/..` sequences from a path
94105function normpath() {
@@ -223,4 +234,4 @@ function runfiles_export_envvars() {
223234 fi
224235 fi
225236}
226- export -f runfiles_export_envvars
237+ export -f runfiles_export_envvars
0 commit comments