mirror of https://github.com/zulip/zulip.git
upgrade: Set an explicit value for PATH.
Previous versions of zulip used `nvm alias default ...` to have `nvm` prepend the full path to the latest `node` install to the `PATH` in root's shell. Unfortunately, this means that `update-prod-static`, when called from `upgrade-zulip-stage-2` after an upgrade of node in `install-node`, would still have the full path to the _old_ `node` at the start of its PATH, because the PATH of `upgrade-zulip-stage-2` would still be unchanged. Bootstrap out of this by setting a known-reasonable PATH during upgrade, and remove the problematic `nvm alias default` behaviour. Fixes #18258.
This commit is contained in:
parent
49144247dd
commit
ebe930ab2c
|
@ -45,8 +45,8 @@ if [ "$current_node_version" != "v$node_version" ] || ! [ -L "$node_wrapper_path
|
|||
. "$NVM_DIR/nvm.sh"
|
||||
fi
|
||||
|
||||
nvm install "$node_version" && nvm alias default "$node_version"
|
||||
NODE_BIN="$(nvm which default)"
|
||||
nvm install "$node_version"
|
||||
NODE_BIN="$(nvm which $node_version)"
|
||||
|
||||
# Fix messed-up uid=500 and group write bits produced by nvm
|
||||
n=${NODE_BIN%/bin/node}
|
||||
|
@ -57,6 +57,12 @@ if [ "$current_node_version" != "v$node_version" ] || ! [ -L "$node_wrapper_path
|
|||
ln -nsf "$NODE_BIN" /usr/local/bin/node
|
||||
ln -nsf "$(dirname "$NODE_BIN")/npm" /usr/local/bin/npm
|
||||
ln -nsf "$(dirname "$NODE_BIN")/npx" /usr/local/bin/npx
|
||||
|
||||
# Tell NVM that we don't want it messing around with $PATH, which
|
||||
# can get us into trouble, if we've just upgraded but our parent
|
||||
# env still has the old version first in its PATH. Tell it to use
|
||||
# the newly-symlinked one that it will find in /usr/local/bin
|
||||
nvm alias default system
|
||||
fi
|
||||
|
||||
# Work around the fact that apparently sudo doesn't clear the HOME
|
||||
|
|
|
@ -37,6 +37,9 @@ from scripts.lib.zulip_tools import (
|
|||
|
||||
assert_running_as_root()
|
||||
|
||||
# Set a known, reliable PATH
|
||||
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
logging.Formatter.converter = time.gmtime
|
||||
logging.basicConfig(format="%(asctime)s upgrade-zulip-stage-2: %(message)s", level=logging.INFO)
|
||||
|
||||
|
|
Loading…
Reference in New Issue