From 112df91fbdbfba3f35f07950f3e3d704b272b6c9 Mon Sep 17 00:00:00 2001 From: Lalit Date: Wed, 11 Jan 2023 17:25:52 +0530 Subject: [PATCH] provision: Do not require that no other yarn precedes us in $PATH. `check_version` in `install-yarn` had the rather careful check that the yarn it installed into `/usr/bin/yarn` was the yarn which was first in the user's `$PATH`. This caused problems when the user had a pre-existing `/usr/local/bin/yarn`; however, those problems are limited to the `install-yarn` script itself, since the nearly all calls to yarn from Zulip's code already hardcode the `/srv/zulip-yarn` location, and do not depend on what is in `$PATH`. Remove the checks in `install-yarn` that depend on the local `$PATH`, and stop installing our `yarn` into it. We also adjust the two callsites which did not specify the full path to `yarn`, so use `/srv/zulip-yarn`. Fixes: #23993 Co-authored-by: Alex Vandiver --- scripts/lib/install-yarn | 5 +---- tools/ci/production-build | 4 +++- tools/setup/optimize-svg | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/lib/install-yarn b/scripts/lib/install-yarn index 46f05808b6..c457428998 100755 --- a/scripts/lib/install-yarn +++ b/scripts/lib/install-yarn @@ -8,9 +8,7 @@ tarball="yarn-$version.tgz" check_version() { # Reading the version of Yarn from its package.json is much faster # than running yarn --version. - link="$(command -v yarn)" \ - && [ "$link" -ef /srv/zulip-yarn/bin/yarn ] \ - && current_version="$(jq -r '.version' /srv/zulip-yarn/package.json)" \ + current_version="$(jq -r '.version' /srv/zulip-yarn/package.json)" \ && [ "$current_version" = "$version" ] } @@ -23,6 +21,5 @@ if ! check_version; then rm -rf /srv/zulip-yarn mkdir /srv/zulip-yarn tar -xzf "$tarball" --no-same-owner --strip-components=1 -C /srv/zulip-yarn - ln -nsf /srv/zulip-yarn/bin/yarn /usr/bin/yarn check_version fi diff --git a/tools/ci/production-build b/tools/ci/production-build index bedfec147e..a524afec75 100755 --- a/tools/ci/production-build +++ b/tools/ci/production-build @@ -44,8 +44,10 @@ cp -a \ /tmp/production-build # Check that webpack bundles use only ES2019 syntax. +# Use the yarn binary installed by tools/provision. +YARN="/srv/zulip-yarn/bin/yarn" tar -C /tmp -xzf /tmp/production-build/zulip-server-test.tar.gz zulip-server-test/prod-static/serve/webpack-bundles ( GLOBIGNORE=/tmp/zulip-server-test/prod-static/serve/webpack-bundles/katex-cli.js - yarn run es-check es2019 /tmp/zulip-server-test/prod-static/serve/webpack-bundles/*.js + $YARN run es-check es2019 /tmp/zulip-server-test/prod-static/serve/webpack-bundles/*.js ) diff --git a/tools/setup/optimize-svg b/tools/setup/optimize-svg index 0ac5f67c02..23efbb4295 100755 --- a/tools/setup/optimize-svg +++ b/tools/setup/optimize-svg @@ -42,6 +42,7 @@ if [ "$#" -gt 0 ]; then fi ZULIP_PATH="$(readlink -f "$(dirname "$0")"/../..)" +YARN="/srv/zulip-yarn/bin/yarn" if [ -n "$CHECK_UNOPTIMIZED" ]; then if [ "$(node_modules/.bin/svgo -f static/images/integrations/logos | grep -o '\.[0-9]% = ' | wc -l)" -ge 1 ]; then @@ -52,6 +53,6 @@ if [ -n "$CHECK_UNOPTIMIZED" ]; then echo "SUCCESS: SVG files in static/images/integrations/logos are all optimized!" fi else - yarn run svgo -q -f static/images/integrations/logos + $YARN run svgo -q -f static/images/integrations/logos "$ZULIP_PATH"/tools/setup/generate_integration_bots_avatars.py fi