git not available for R / RStudio in macOS Catalina

Viewed 1918

I just updated to macOS Catalina (v10.15) and found out that neither git commands nor the 'git' pane is available in RStudio after this update.

Now when I open the Terminal pane in RStudio and type:

git status

I get this error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun

How to solve this? I downloaded and reinstalled the latest git (2.23.0) but that's not working. I use the latest RStudio (1.2.5001) with R 3.6.1.

I changed to the zsh shell as Terminal.app suggested when I opened it after the update, with chsh -s /bin/zsh.

2 Answers

From macOS v10.15 (Catalina) on, zsh is the new default shell for new users, replacing bash. I am not sure if this is related to (or causing) the problem, but it might. Depends if the user profile was created after the update, or the user 'activated' zsh e.g. by using chsh -s /bin/zsh.

Behind the scenes, if you run /usr/bin/git, the binary loads functions in libxcselect.dylib that can locate the path to the real binary, depending on how the system has been configured. One part of this process is to check whether this path contains usr/lib/libxcrun.dylib, and the xcrun tool, in which case it will invoke xcrun to run the binary.

The xcrun binary is present in developer directories included with Xcode, so you have to install it. Open Terminal.app and enter:

xcode-select --install

After this, RStudio will remember git again :) Just restart RStudio and everything will be fine.

Had the same issue. Quit RStudio, download Xcode from the app store, open Xcode...it will install developer tools, quit Xcode and open RStudio and Git reappeared.

Related