Skip to content

Commit

Permalink
[๐Ÿ”ฅAUDIT๐Ÿ”ฅ] Do not look in a subdir for java11 in the M1 case. (#110)
Browse files Browse the repository at this point in the history
๐Ÿ– _This is an audit!_ ๐Ÿ–

## Summary:
java lives in one of these directories:
```
/usr/local/Cellar/openjdk@11/11.<something>     # x86_64
/opt/homebrew/Cellar/openjdk@11/11.<something>  # M1
```

But M1 has a convenience symlink `/opt/homebrew/opt/openjdk@11`, which
points directly into `/opt/homebrew/Cellar/openjdk@11/11.<something>`.
I thought it pointed just to `/opt/homebrew/Cellar/openjdk@11`, but I
was wrong.  That means we shouldn't look for the `11.*` dir ourselves,
in the M1 case.

Issue: https://khanacademy.slack.com/archives/C04SEFXQBNU/p1709587347376909

## Test plan:
Fingers crossed, James is going to try it.

Author: csilvers

Auditors: #infra-platform

Required Reviewers:

Approved By:

Checks:

Pull Request URL: #110
  • Loading branch information
csilvers authored Mar 5, 2024
1 parent 778d333 commit 4505d89
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions shared-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,11 @@ install_mac_java() {
if [ -d /opt/homebrew/opt/openjdk@11 ]; then
brew_loc=/opt/homebrew/opt/openjdk@11
elif [ -d /usr/local/Cellar/openjdk@11 ]; then
brew_loc=/usr/local/Cellar/openjdk@11
# Different versions are installed here, we'll take the latest.
brew_loc=$(ls -td /usr/local/Cellar/openjdk@11/11.* | head -n1)
else
error "Could not find the location of java 11, not installing it"
fi
# Different versions are installed here, we'll take the latest.
brew_loc=$(ls -td "$brew_loc"/11.* | head -n1)
sudo ln -sfn "$brew_loc"/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

# Ensure JAVA_HOME is set in ~/.profile.khan
Expand Down

0 comments on commit 4505d89

Please sign in to comment.