r-lib / fs

Provide cross platform file operations based on libuv.
https://fs.r-lib.org/
Other
368 stars 80 forks source link

Installing "devtools"/"use this" in R 3.62 and 3.6.3 #260

Closed matrapp closed 4 years ago

matrapp commented 4 years ago

I have tried to install "devtools" in both R 3.6.3 and 3.6.2 (running on Catalina 10.15.4) and I had the same problems in both versions:

When installing "usethis" I get the error message: "### installation of package ‘fs’ had non-zero exit status" as you can see bellow.

> install.packages("usethis")
Installing package into ‘/Users/trappma/Library/R/3.6/library’
(as ‘lib’ is unspecified)
also installing the dependency ‘fs’

  There is a binary version available but the source version is later:
   binary source needs_compilation
fs  1.3.2  1.4.0              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/usethis_1.5.1.tgz'
Content type 'application/x-gzip' length 912856 bytes (891 KB)
==================================================
downloaded 891 KB

The downloaded binary packages are in
    /var/folders/r4/2xf454s53lx_6ts3ctg5rmm90hbnrh/T//Rtmp24MWka/downloaded_packages
installing the source package ‘fs’

trying URL 'https://cran.rstudio.com/src/contrib/fs_1.4.0.tar.gz'
Content type 'application/x-gzip' length 819599 bytes (800 KB)
==================================================
downloaded 800 KB

* installing *source* package ‘fs’ ...
** package ‘fs’ 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 ‘fs’
* removing ‘/Users/trappma/Library/R/3.6/library/fs’
Warning in install.packages :
  installation of package ‘fs’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/r4/2xf454s53lx_6ts3ctg5rmm90hbnrh/T/Rtmp24MWka/downloaded_packages’

Could someone please help with that? Thank you very much Best

jimhester commented 4 years ago

In order to compile packages with compiled code from source you need to have the Xcode toolkit installed. See also https://rstats.wtf/set-up-an-r-dev-environment.html#macos-system-prep for more background.

Googling 'xcrun: error: invalid active developer path' gives me this as the first result, which should give the the solution.

The fix, luckily, is pretty straight forward. Install the Xcode toolkit! Even if you had it installed before, you might have to re-register it or update it to the latest version.

So you need to run the following in a terminal application.

xcode-select --install

Alternatively you can select 'No' to the prompt and install the binary instead, which does not require the ability to compile packages.