I can´t install packages on R studio, "non-zero exit status"

Hi
I have been using R studio for the past couple of years and it has worked great, until recently. For some reson (not sure what changed) a couple of months ago I was unable to install packages on R studio, it connects (downloads the packages) but then it always gives me a "non-zero exit status" so it erases everything that was downloaded. Initially, I thought it was my computer telling me to update so I updated MacOS to Catalina. I uninstall R and R studio and installed the last versions (and just did again) and I still can´t. I am able in R, but not R Studio for some reason. I can´t say it is because of the operating system because the issue was there before...

Here it is:
Everything is downloaded successfully but then this error appears on everything

trying URL 'http://mirror.its.dal.ca/cran/src/contrib/tidyverse_1.3.0.tar.gz'
Content type 'application/x-gzip' length 712837 bytes (696 KB)

downloaded 696 KB

  • installing source package ‘sys’ ...
    ** package ‘sys’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    ERROR: compilation failed for package ‘sys’
  • removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sys’
    Warning in install.packages :
    installation of package ‘sys’ had non-zero exit status
  • installing source package ‘ps’ ...
    ** package ‘ps’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    ERROR: compilation failed for package ‘ps’
  • removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/ps’
    Warning in install.packages :
    installation of package ‘ps’ had non-zero exit status
  • installing source package ‘highr’ ...
    ** package ‘highr’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
  • DONE (highr)
  • installing source package ‘rematch’ ...
    ** package ‘rematch’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
  • DONE (rematch)
  • installing source package ‘prettyunits’ ...
    ** package ‘prettyunits’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
  • DONE (prettyunits)
  • installing source package ‘yaml’ ...
    ** package ‘yaml’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    ERROR: compilation failed for package ‘yaml’
  • removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/yaml’
    Warning in install.packages :
    installation of package ‘yaml’ had non-zero exit status

Any recommendations/comments/suggestions? Helpppp
thank you
JOHC

2 Likes

Hi, and welcome.

For future reference, please see FAQ: What's a reproducible example (`reprex`) and how do I do one?, although it's not needed for your problem.

I see you're on MAC OS, and there is an alignment of problems today.

R package come in two flavors: binary and source. Saint Simon Urbanek of the R Core Development Team, does the occasionally heavy lifting to get the source code to successfully compile. Whenever it's an option, this is the way to go.

Unfortunately, the CRAN repository had a very rare glitch, and the mirrors all reflected it. It will be shortly fixed, but in the meantime

 install.packages("tidyverse", repo = 'https://mac.R-project.org')

should work.

But sometimes, you run into a situation where you need a package for which no source version has yet been prepared. This can get dicey.

First, you need to download and install the free XCode app from the App Store.

Second, from the terminal, you need to run the command

$ xcode-select --install

Now, you can perhaps compile from source. Short programs usually succeed, unless they have uninstalled dependencies, which can be fixed with other tools, but it's an intermediate to advanced process. Some programs won't compile even if you do have the required dependencies, because they use codes that Apple's compiler doesn't play well with To fix that problem, you have to edit the source code.

R users like me, who are basically interested in using R, rather than programming the R plumbing don't want to spend their time re-coding even if they can.

3 Likes

Wow amazing, I have been bathling with this for a while, it worked perfectly thank you!

1 Like

For reference, the CRAN binary repositories for macOS were briefly corrupted; this is likely why you were seeing this issue. Everything should be resolved now.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.