Skip to content

Commit

Permalink
Fixes for new machine install
Browse files Browse the repository at this point in the history
Summary:
While re-installing onto a brand new install, I ran into several issues and noticed some things that are no longer needed. Specifically:
* Installing `yarn` via homebrew has the potential to overwrite the `node` we have installed (usually with a newer version than we want). Instead, it's easiest to just use `npm` to install yarn globally.
* `readline` is a [[ https://khanacademy.slack.com/archives/C02NMB1R5/p1606758044205900 | perenial ]] [[ https://khanacademy.slack.com/archives/C02NMB1R5/p1601497407132100 | problem ]] to get installed with `pip`. But our version of Python comes with `readline` packaged into it, and that version of readline properly switches between readline and libedit (macOS) depending on the OS it's on. I don't think we need to install the readline module manually any longer (see https://pypi.org/project/gnureadline/)
* Don't force-install [email protected] - that breaks `make install_deps` in webapp

Issue: "none"

Test Plan: Well, I guess the best way would be to run this diff on a fresh install of macOS.

Reviewers: ebrown, csilvers, benkraft

Reviewed By: ebrown

Subscribers: bryan, john, kevinb, jeff, csilvers

Differential Revision: https://phabricator.khanacademy.org/D68282
  • Loading branch information
jeremywiebe committed Jan 14, 2021
1 parent e66ad9a commit 80267e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 33 deletions.
11 changes: 3 additions & 8 deletions mac-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,6 @@ install_node() {
notice "\t${tty_bold}brew link --force --overwrite node@12${tty_normal}"
read -p "Press enter to continue..."
fi
if ! which yarn >/dev/null 2>&1; then
# Using brew to install node 10 seems to prevent npm from
# correctly installing yarn. Use brew instead
brew install yarn
fi
}

install_go() {
Expand Down Expand Up @@ -342,9 +337,9 @@ install_postgresql() {
if [ "$pg11_brewname" = "NONE" ] ; then
info "Installing postgresql\n"
brew install postgresql@11
# swtich icu4c to 64.2
# if default verison is 63.x and v64.2 was installed by postgres@11
if [ "$(brew ls icu4c --versions |grep "icu4c 63")" ] && \
# switch icu4c to 64.2
# if default version is 63.x and v64.2 was installed by postgres@11
if [ "$(brew ls icu4c --versions | grep "icu4c 63")" ] && \
[ "$(brew ls icu4c | grep 64.2 >/dev/null 2>&1)" ]; then
brew switch icu4c 64.2
fi
Expand Down
11 changes: 2 additions & 9 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,9 @@ install_deps() {

create_and_activate_virtualenv "$ROOT/.virtualenv/khan27"

# Inspiration from this slack discussion
# https://khanacademy.slack.com/archives/C0918TZ5G/p1560899833202100
# In general, need to pin npm to V6.4.1
# Also, need to install yarn first before run `make install_deps`
# Need to install yarn first before run `make install_deps`
# in webapp.
# TODO(avidal): Is this still necessary? That's an ancient version of npm
# and you can get yarn via brew or via your distribution.
if ! which yarn >/dev/null; then
echo "Installing yarn"
sudo npm install -g [email protected]
if ! which yarn >/dev/null 2>&1; then
sudo npm install -g yarn
fi

Expand Down
17 changes: 1 addition & 16 deletions shared-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ has_recent_go() {

# Creates a webapp virtualenv in $1, if none exists, then activates it.
#
# Assumes pip and virtualenv are already installed. Note this also
# pre-installs the correct readline on OS X -- see comments below.
# Assumes pip and virtualenv are already installed.
#
# Arguments:
# $1: directory in which to put the virtualenv, typically ~/.virtualenv/khan27.
Expand All @@ -164,20 +163,6 @@ create_and_activate_virtualenv() {

# Activate the virtualenv.
. "$1/bin/activate"

# On OSX 10.15, we need to install an older version of readline
# so that when pip will not install the latest, which results
# in a library error trying to load readline/libreadline.a
# This must be done after installing the virtualenv.
if [ "`uname -s`" == "Darwin" ] && sw_vers -productVersion | grep -q -e '^10\.15\.'; then
echo "On OSX 10.15 - Installing readline 6.2.0"
if [ -z "$(pip --disable-pip-version-check freeze | grep readline)" ] ; then
# Long deprecated library - clang generates many warnings which
# cause build to fail. We add a -w here to disable *all* warnings.
# It is the only way found to get the install to work.
CFLAGS='-w' pip install https://pypi.python.org/packages/source/r/readline/readline-6.2.0.tar.gz
fi
fi
}

# If we exit unexpectedly, log this warning.
Expand Down

0 comments on commit 80267e8

Please sign in to comment.