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"
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.