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 <alexmv@zulip.com>
This commit is contained in:
Lalit 2023-01-11 17:25:52 +05:30 committed by Alex Vandiver
parent 4811443b3d
commit 112df91fbd
3 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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
)

View File

@ -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