Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit 4e36794

Browse files
authored
fix(yarn): setup a fallback strategy for workspace detection and non-corepack logic (#862)
1 parent aca5d7a commit 4e36794

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,13 @@ ENV PNPM_VERSION=7.13.4
291291

292292
ENV NETLIFY_NODE_VERSION="16"
293293

294+
# We install an "internal" yarn v1 executable to be used only for workspace detection. We can remove it once we have a better
295+
# strategy in place
294296
RUN /bin/bash -c ". ~/.nvm/nvm.sh && \
295297
nvm install --no-progress $NETLIFY_NODE_VERSION && \
296298
npm install -g grunt-cli bower && \
297299
nvm alias default node && \
300+
bash /usr/local/bin/yarn-installer.sh --version $YARN_VERSION && \
298301
nvm cache clear && \
299302
corepack enable && \
300303
corepack prepare yarn@$YARN_VERSION --activate && \

run-build-functions.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ DEFAULT_SWIFT_VERSION="5.4"
2525
# PHP version
2626
DEFAULT_PHP_VERSION="8.0"
2727

28+
# Internal yarn config
29+
# We use an "internal" yarn v1 executable as to not be impacted by corepack yarn selection
30+
INTERNAL_YARN_PATH="$HOME/.yarn/bin"
31+
2832
# Pipenv configuration
2933
export PIPENV_RUNTIME=3.8
3034
export PIPENV_VENV_IN_PROJECT=1
@@ -107,7 +111,7 @@ restore_node_modules() {
107111
# YARN_IGNORE_PATH will ignore the presence of a local yarn executable (i.e. yarn 2) and default
108112
# to using the global one (which, for now, is always yarn 1.x). See https://yarnpkg.com/configuration/yarnrc#ignorePath
109113
# we can actually use this command for npm workspaces as well
110-
workspace_output="$(YARN_IGNORE_PATH=1 yarn workspaces --json info 2>/dev/null)"
114+
workspace_output="$(YARN_IGNORE_PATH=1 "$INTERNAL_YARN_PATH/yarn" workspaces --json info 2>/dev/null)"
111115
workspace_exit_code=$?
112116
if [ $workspace_exit_code -eq 0 ]
113117
then
@@ -137,6 +141,10 @@ run_yarn() {
137141
restore_home_cache ".yarn_cache" "yarn cache"
138142

139143
if ! [ $(which corepack) ] || has_feature_flag "$featureFlags" "build-image-disable-node-corepack"; then
144+
145+
# We manually add our internal yarn version to our path as a fallback, as this means the customer won't have a default
146+
# yarn version installed
147+
export PATH=$INTERNAL_YARN_PATH:$PATH
140148
if [ -d $NETLIFY_CACHE_DIR/yarn ]
141149
then
142150
export PATH=$NETLIFY_CACHE_DIR/yarn/bin:$PATH

0 commit comments

Comments
 (0)