2

I've been trying to install devtools in R on MacOS, first by using in RStudio:

install.packages("devtools")

and then using as an alternative:

install.packages("devtools",lib="/usr/local/Cellar/r/3.6.0_3/lib/R/library")

This gave permission errors, therefore I then used the terminal:

sudo R

then using the same commands as in RStudio to install the package, which gave me the following error(s) for both commands:

1: In install.packages("devtools", lib = "/usr/local/Cellar/r/3.6.0_3/lib/R/library") :
  installation of package ‘xml2’ had non-zero exit status

2: In install.packages("devtools", lib = "/usr/local/Cellar/r/3.6.0_3/lib/R/library") :
  installation of package ‘roxygen2’ had non-zero exit status

3: In install.packages("devtools", lib = "/usr/local/Cellar/r/3.6.0_3/lib/R/library") :
  installation of package ‘devtools’ had non-zero exit status

I do not have experience using R, and the solutions mentioned online when using Ubunu or CentOS do not work.

Please let me know if you have suggestions on how to install devtools and what is causing these errors, any suggestions are highly appreciated. Thank you in advance!

Using dependencies=TRUE does a lot more installations, but still gives the following result:

The downloaded source packages are in
    ‘/private/tmp/RtmptCt93z/downloaded_packages’
Warning messages:
1: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘xml2’ had non-zero exit status

2: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘RCurl’ had non-zero exit status

3: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘rvest’ had non-zero exit status

4: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘roxygen2’ had non-zero exit status

5: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘rversions’ had non-zero exit status

6: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘spelling’ had non-zero exit status

7: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘rsconnect’ had non-zero exit status

8: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘foghorn’ had non-zero exit status

9: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘devtools’ had non-zero exit status

10: In install.packages("devtools", dependencies = TRUE) :
  installation of package ‘pkgdown’ had non-zero exit status

I tried manually adding the path shown in RStudio to my .bash_profile, which resulted in my terminal not knowing any commands (sudo, nano, etc) anymore, which way would be the correct one to do this, is maybe the path to R the problem?

> R.home()
[1] "/usr/local/Cellar/r/3.6.0_3/lib/R"
Emily
  • 354
  • 3
  • 10
  • What happens during the installation? What other messages are displayed? Did you try installing with dependencies set to TRUE(`install.packages("devtools",dependencies=TRUE)`)? – NelsonGon Jul 08 '19 at 12:41
  • @NelsonGon, Thank you for your suggestion, I've pasted the reslt that gives as edit in my question (it was too long for a comment) – Emily Jul 08 '19 at 13:12
  • 1
    I think it has to do with lack of a compiler and/or necessary compiler packages. Not an OSX user but I think running this might help : `brew install libsvg curl libxml2 gdal geos boost`. See also:https://rud.is/b/2015/10/22/installing-r-on-os-x-100-homebrew-edition/ More detailed post: https://stackoverflow.com/questions/20923209/problems-installing-the-devtools-package – NelsonGon Jul 08 '19 at 13:14
  • @NelsonGon, after running your last suggestion I still get the same issue, maybe I need to add a path (R?) to my .bash_profile? I have tried to figure out how and which one, any suggestions? – Emily Jul 08 '19 at 13:42
  • 1
    I don't think it's an issue with R itself,try installing this first: https://thecoatlessprofessor.com/programming/r-compiler-tools-for-rcpp-on-macos/ – NelsonGon Jul 08 '19 at 14:55
  • @NelsonGon, Thank you for this page and your help, unfortunately I still encounter the same problems after walking through all the steps in the article successfully. – Emily Jul 08 '19 at 20:53
  • Tough luck,hopefully someone picks up on the issue and helps you solve it. Otherwise, you could try manually installing it and see if it works. – NelsonGon Jul 09 '19 at 03:26

1 Answers1

1

I finally solved it by downloading devtools directly via https://cran.r-project.org/web/packages/devtools/devtools.pdf (as suggested by @NelsonGon)

Then moving that folder to R.home()/library

then running devtools using sudo in the terminal to install github packages.

Emily
  • 354
  • 3
  • 10
  • Hi @Emily Can you please share the final steps / commands you ran when you say "... then running devtools using sudo in the terminal to install github packages." ? I am in the exact situation as you were. – dat789 Jul 10 '19 at 08:58
  • Hi @dat789, sorry for the short notation. I did: `sudo R` in my command line, then in the terminal in R: `install.packages('devtools')` – Emily Sep 06 '19 at 23:01