xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun ERROR: compilation failed for package ‘rlang’

Unfortunately, it didn't work. Still get the same error for dplyr.

Restarting R session...

> install.packages("rlang")

  There is a binary version available but the source version is later:
      binary source needs_compilation
rlang  0.3.1  0.3.3              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) y
installing the source package ‘rlang’

trying URL 'https://cran.rstudio.com/src/contrib/rlang_0.3.3.tar.gz'
Content type 'application/x-gzip' length 859027 bytes (838 KB)
==================================================
downloaded 838 KB

* installing *source* package ‘rlang’ ...
** package ‘rlang’ successfully unpacked and MD5 sums checked
** libs
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
ERROR: compilation failed for package ‘rlang’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rlang’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rlang’
Warning in install.packages :
  installation of package ‘rlang’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/dv/q61b2y795bbcs2kkg7zqq_qm0000gn/T/RtmpjefZx7/downloaded_packages’
> library("dplyr", lib.loc="/Library/Frameworks/R.framework/Versions/3.5/Resources/library")
Error: package or namespace load failed for ‘dplyr’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 namespace ‘rlang’ 0.3.0.1 is already loaded, but >= 0.3.1 is required
In addition: Warning message:
package ‘dplyr’ was built under R version 3.5.2 
> library("rlang", lib.loc="/Library/Frameworks/R.framework/Versions/3.5/Resources/library")
> library(dplyr)
Error: package or namespace load failed for ‘dplyr’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 namespace ‘rlang’ 0.3.0.1 is already loaded, but >= 0.3.1 is required
In addition: Warning message:
package ‘dplyr’ was built under R version 3.5.2