Files
zulip/scripts/lib/install-yarn
Lalit 112df91fbd 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>
2023-01-19 17:51:52 -05:00

26 lines
765 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
version=1.22.19
sha256=732620bac8b1690d507274f025f3c6cfdc3627a84d9642e38a07452cc00e0f2e
tarball="yarn-$version.tgz"
check_version() {
# Reading the version of Yarn from its package.json is much faster
# than running yarn --version.
current_version="$(jq -r '.version' /srv/zulip-yarn/package.json)" \
&& [ "$current_version" = "$version" ]
}
if ! check_version; then
tmpdir="$(mktemp -d)"
trap 'rm -r "$tmpdir"' EXIT
cd "$tmpdir"
curl -fLO --retry 3 "https://registry.npmjs.org/yarn/-/$tarball"
sha256sum -c <<<"$sha256 $tarball"
rm -rf /srv/zulip-yarn
mkdir /srv/zulip-yarn
tar -xzf "$tarball" --no-same-owner --strip-components=1 -C /srv/zulip-yarn
check_version
fi