Browse Source

fix(dev): Install Command Line Tools when git is missing (#30050)

When upgrading Mac, it sometimes seems to remove the Command Line Tools, thus, git becomes unavailable.

This change helps developers to simply install the tools and not be confused about xcrun message.
Armen Zambrano G 3 years ago
parent
commit
3ecc18ec89
1 changed files with 10 additions and 0 deletions
  1. 10 0
      .envrc

+ 10 - 0
.envrc

@@ -5,6 +5,16 @@
 # If you'd like to override or set any custom environment variables, this .envrc will read a .env file at the end.
 set -e
 
+# Upgrading Mac can uninstall the Command Line Tools, thus, removing our access to git
+# The message talks about xcrun, however, we can use the lack of git as a way to know that we need this
+# xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),
+# missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
+if [ "$(uname -s)" == "Darwin" ] && [ ! -f "/Library/Developer/CommandLineTools/usr/bin/git" ]; then
+    echo -e "$(tput setaf 1)\nERROR: Complete the interactive installation (10+ mins) of the Command Line Tools.$(tput sgr0)"
+    xcode-select --install
+    return 1
+fi
+
 SENTRY_ROOT="$(
     cd "$(dirname "${BASH_SOURCE[0]}")"
     pwd -P