install: Clarify how we set locale during install, and why.

This updates commit 11ab545f3 "install: Set the locale ..."
to be somewhat cleaner, and to explain more in the commit message.

In some environments, either pip itself fails or some packages fail to
install, and setting the locale to en_US.UTF-8 resolves the issue.

We heard reports of this kind of behavior with at least two different
sets of symptoms, with 1.7.0 or its release candidates:
  https://chat.zulip.org/#narrow/stream/general/subject/Trusty.201.2E7.20Upgrade/near/302214
  https://chat.zulip.org/#narrow/stream/production.20help/subject/1.2E6.20to.201.2E7/near/306250

In all reported cases, commit 11ab545f3 or equivalent fixed the issue.

Setting LC_CTYPE is redundant when also setting LC_ALL, because LC_ALL
overrides all `LC_*` environment variables; so skip that.  Also move
the line in `install` to a more appropriate spot, and adjust the
comments.
This commit is contained in:
Greg Price 2017-11-22 18:03:44 -08:00
parent 59870b2203
commit 64c608a51a
2 changed files with 6 additions and 9 deletions

View File

@ -1,11 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
# Ensure that we're using a US locale, since some pip dependencies
# can't install in random locales.
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
usage() { usage() {
cat <<EOF cat <<EOF
Usage: Usage:
@ -59,6 +54,9 @@ fi
# Do set -x after option parsing is complete # Do set -x after option parsing is complete
set -x set -x
# Force a known locale. Some packages on PyPI fail to install in some locales.
export LC_ALL="en_US.UTF-8"
# Specify options for apt. # Specify options for apt.
APT_OPTIONS="${APT_OPTIONS:-}" APT_OPTIONS="${APT_OPTIONS:-}"
# Install additional packages using apt. # Install additional packages using apt.

View File

@ -11,10 +11,9 @@ import sys
import logging import logging
os.environ["PYTHONUNBUFFERED"] = "y" os.environ["PYTHONUNBUFFERED"] = "y"
# Ensure that we're using a US locale, since some pip dependencies
# can't install in random locales. # Force a known locale. Some packages on PyPI fail to install in some locales.
os.environ['LC_ALL'] = "en_US.UTF-8" os.environ["LC_ALL"] = "en_US.UTF-8"
os.environ['LC_CTYPE'] = "en_US.UTF-8"
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, su_to_zulip from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, su_to_zulip