Installing R package "validate" exits with error - r

I'm trying to install the package validate using install.package("validate"), but I get the following error message:
Installing package into ‘C:/Users/xxx/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
validate 0.9.3 1.0.1 TRUE
installing the source package ‘validate’
trying URL 'https://cran.rstudio.com/src/contrib/validate_1.0.1.tar.gz'
Content type 'application/x-gzip' length 1990096 bytes (1.9 MB)
downloaded 1.9 MB
* installing *source* package 'validate' ...
** package 'validate' successfully unpacked and MD5 sums checked
** using staged installation
** libs
*** arch - i386
C:/Program Files/R-Tools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-3.6.1/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c R_fdep.c -o R_fdep.o
sh: C:/Program: No such file or directory
make: *** [C:/PROGRA~1/R/R-3.6.1/etc/i386/Makeconf:208: R_fdep.o] Error 127
ERROR: compilation failed for package 'validate'
* removing 'C:/Users/xxx/Documents/R/win-library/3.6/validate'
* restoring previous 'C:/Users/xxx/Documents/R/win-library/3.6/validate'
Warning in install.packages :
installation of package ‘validate’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\xxx\AppData\Local\Temp\2\Rtmp08xXa8\downloaded_packages’
I've tried installing the package on my local machine and there I have no issues. This issues occurs when I try installing the package on a Azure-Cloud. Other packages install fine however. Also when I install the package using the "binary" option, it works fine... That is, howeverm, not the most recent version and there are some functionallities we want to use from the newest version.
Has anyone else encountered this problem and has a solution?

With the Help of user20650 I was able to find a solution.
We have an older version of R and R-Studio installed on our Cloud. This causes issues when installing packages with install.packages. Apparently only the newest source-file, but not the newest binary is considered. To overcome this I needed to download the binary manualy from cran. Then I installed the binary in R-Studio using Tools -> Install Packages... -> Install from: Package Archive file -> select Binary

Related

Reinstalling R Packages in New Location after R Update

I'm pretty new to R, but I've used it a little bit. However, I'm running into a problem and can't figure it out, despite having read through over a dozen other resources. For reasons I won't get into, I had to update R and R Studio. However, now none of my packages will install. For example, when I try to install dplyr, this is what I get:
> install.packages("dplyr")
There is a binary version available but the source version is later:
binary source needs_compilation
dplyr 1.0.10 1.1.0 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘dplyr’
trying URL 'https://cran.rstudio.com/src/contrib/dplyr_1.1.0.tar.gz'
Content type 'application/x-gzip' length 1068347 bytes (1.0 MB)
==================================================
downloaded 1.0 MB
* installing *source* package ‘dplyr’ ...
** package ‘dplyr’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/usr/local/Cellar/gcc/9.2.0/bin/g++-7 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c chop.cpp -o chop.o
/bin/sh: /usr/local/Cellar/gcc/9.2.0/bin/g++-7: No such file or directory
make: *** [chop.o] Error 127
ERROR: compilation failed for package ‘dplyr’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/dplyr’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/dplyr’
Warning in install.packages :
installation of package ‘dplyr’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/k7/pbrcjpr517x06fhvnkvbq0nc0000gp/T/RtmpAODLeZ/downloaded_packages’
>
From what I've seen on other questions like this, I need to reinstall the packages to a new location. However, let's assume I'm an idiot and I have no idea how to re-install them somewhere else, where to install them, or how to make R/Rstudio that is where my packages can now be found. Can someone help me figure this out?
EDIT:
I now know that the problem is that it can't find the g++-7 dictionary, but I don't know why it is trying to find the g++-7, when my terminal says it my current version (12) is g++-12. Why would R not try to download the packages to my most recent version?
(base) Liams-MacBook-Pro:~ lessig7$ brew list gcc
/usr/local/Cellar/gcc/12.2.0/bin/c++-12
/usr/local/Cellar/gcc/12.2.0/bin/cpp-12
/usr/local/Cellar/gcc/12.2.0/bin/g++-12
/usr/local/Cellar/gcc/12.2.0/bin/gcc-12
/usr/local/Cellar/gcc/12.2.0/bin/gcc-ar-12
/usr/local/Cellar/gcc/12.2.0/bin/gcc-nm-12
/usr/local/Cellar/gcc/12.2.0/bin/gcc-ranlib-12
/usr/local/Cellar/gcc/12.2.0/bin/gcov-12
/usr/local/Cellar/gcc/12.2.0/bin/gcov-dump-12
/usr/local/Cellar/gcc/12.2.0/bin/gcov-tool-12
/usr/local/Cellar/gcc/12.2.0/bin/gfortran
/usr/local/Cellar/gcc/12.2.0/bin/gfortran-12
/usr/local/Cellar/gcc/12.2.0/bin/lto-dump-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-c++-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-g++-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-gcc-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-gcc-ar-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-gcc-nm-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-gcc-ranlib-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-gfortran-12
/usr/local/Cellar/gcc/12.2.0/include/c++/ (806 files)
/usr/local/Cellar/gcc/12.2.0/lib/gcc/ (719 files)
Once I realized R was trying to save it to an olde version, I tried to tell it to save to the new folder with the following code (just changing the version numbers to match what is on my terminal):
install.packages("dplyr", lib="/usr/local/Cellar/gcc/12.2.0/bin/c++-12/Library/Frameworks/R.framework/Resources/include")
However, that produced the following error:
install.packages("dplyr", lib="/usr/local/Cellar/gcc/12.2.0/bin/c++-12/Library/Frameworks/R.framework/Resources/include")
Warning in install.packages :
'lib = "/usr/local/Cellar/gcc/12.2.0/bin/c++-12/Library/Frameworks/R.framework/Resources/include"' is not writable
Would you like to use a personal library instead? (yes/No/cancel)
Error in install.packages : unable to install packages
>
install.packages("dplyr", lib="/usr/local/Cellar/gcc/12.2.0/bin/c++-12/Library/Frameworks/R.framework/Resources/include")
I'd really appreciate any help. Thank you in advance.
It looks like the problem you're encountering is due to a missing version of g++.
The error message says:
/usr/local/Cellar/gcc/9.2.0/bin/g++-7: No such file or directory
This means that the g++ compiler, which is necessary for installing some R packages, is not present in the specified location /usr/local/Cellar/gcc/9.2.0/bin/g++-7.
To fix the issue, you can try installing the g++ compiler by running the following command in your terminal:
brew install gcc
After installing g++, try installing the dplyr package again in R. If you continue to face issues, you can try reinstalling the package to a different location by using the lib argument in the install.packages function, for example:
install.packages("dplyr", lib="/path/to/new/library")
Replace "/path/to/new/library" with the desired location for the installed packages.

Installing package "quantreg" in R fails with "had non-zero exit status"

My aim is to install the R package "quantreg". In R Studio, I therefore type
install.packages("quantreg")
R Studio then prints:
binary source needs_compilation
quantreg 5.85 5.88 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel)
I consequently write "Yes" and hit enter. The installation then fails with the following output:
installing the source package ‘quantreg’
trying URL 'https://cran.rstudio.com/src/contrib/quantreg_5.88.tar.gz'
Content type 'application/x-gzip' length 1016964 bytes (993 KB)
==================================================
downloaded 993 KB
* installing *source* package ‘quantreg’ ...
** package ‘quantreg’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gfortran -fPIC -Wall -g -O2 -c akj.f -o akj.o
make: gfortran: No such file or directory
make: *** [akj.o] Error 1
ERROR: compilation failed for package ‘quantreg’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/quantreg’
Warning in install.packages :
installation of package ‘quantreg’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/bl/yxw71y6n3ksbktr_vmp65h1m0000gn/T/Rtmpc1SB0G/downloaded_packages’
I am on Mac OS 12.3.1 Monterey and use R version 3.6.3. I use this old version of R (instead of an up-to-date one) because it is required in combination with another program that I use. Therefore, I cannot use newer versions of R.
What could be a possible fix for my problem, so that R installs quantreg without failing?

Error message when installing xml2 R package

After updating to R 4.0.0 on my Windows machine, I can't install some packages such as xml2 (the same goes for foreign and nnet). When I try to install I get this error message:
* installing *source* package 'foreign' ...
** package 'foreign' successfully unpacked and MD5 sums checked
** using staged installation
** libs
*** arch - i386
"c:/rtools40/mingw32/bin/"gcc -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c R_systat.c -o R_systat.o
sh: c:/rtools40/mingw32/bin/gcc: No such file or directory
make: *** [C:/PROGRA~1/R/R-40~1.0/etc/i386/Makeconf:222: R_systat.o] Error 127
ERROR: compilation failed for package 'foreign'
* removing 'C:/R-PKGS/win-library/3.6/foreign'
* restoring previous 'C:/R-PKGS/win-library/3.6/foreign'
Warning in install.packages :
installation of package ‘foreign’ had non-zero exit status
The main reason for installing the xml2 package is that I want to use the tidyverse package, but when I try to run library(tidyverse) I get this message:
Error: package or namespace load failed for ‘tidyverse’:
package ‘xml2’ was installed before R 4.0.0: please re-install it
So I guess that I will have to be able to solve the problem that occurs when I try to install the xml2 package as it may occur in the future when other packages will have to be updated.
Kind regards, Andrés
R 4.0 on Windows is accompanied with a new tool set rtools40 that can be installed separately. The tool set contains compilers and other programming tools to install source code packages on Windows, while the compilers are usually already available on Linux systems. The tool set can be installed from CRAN, but it is usually not necessary, if only pre-compiled "binary packages" are installed.
An additional confusion can sometimes occur if packages from different versions of R are installed in the same folder, the so-called "personal library", in Windows by default:
c:\users\<username>\R\win-library
... or another user-specified folder. After updating to a new R version, it can be a good idea to clean up older win-libraries. Make sure, that the folders do not contain valuable personal data.

RStudio can't install "igraph" - C compiler cannot create executables

Im using anaconda, so RStudio 1.1.456.
When I try to
install.packages("igraph")
I get this message:
trying URL 'https://cran.rstudio.com/src/contrib/igraph_1.2.4.1.tar.gz'
Content type 'application/x-gzip' length 2704004 bytes (2.6 MB)
==================================================
downloaded 2.6 MB
* installing *source* package ‘igraph’ ...
** package ‘igraph’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/private/var/folders/x1/zlhhtxm951v95d461h7d09bc0000gn/T/Rtmp0iNakh/R.INSTALL16a5d3eb16782/igraph':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘igraph’
* removing ‘/Users/RobinHorn/anaconda3/envs/Data_Analysis/lib/R/library/igraph’
Warning in install.packages :
installation of package ‘igraph’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/x1/zlhhtxm951v95d461h7d09bc0000gn/T/RtmpYbzkOw/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
So it looks like my C compiler is not working.
What I tried already:
installing command line tools
xcode-select --install
installing missing headers:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
This results in:
installer: Error - the package path specified was invalid: '/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg'.
gcc seems to be installed correctly:
~ % gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
~ %
I ran across your post because I had the same problem. My answer hinges on one question: do you really need to access RStudio through Anaconda? If your answer is "no," then the solution is simple:
I downloaded RStudio from rstudio.com and installed it directly on my Mac; the version happens to be 1.2.5033. Now when I install
install.packages("igraph")
everything works fine. I have tested several functions with no problem (but don't forget to load the package).
Note that when I return to RStudio through Anaconda, it still does not work. Apparently, Anaconda keeps its own copy of the install tree but does not play nicely with certain packages ...

installing R gsl package on Mac

I'm trying to install the gsl package for R, which I understand is simply a wrapper around the GSL, under OSX Mavericks. I've tried the obvious:
> install.packages('gsl')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
package ‘gsl’ is available as a source package but not as a binary
Warning in install.packages :
package ‘gsl’ is not available (for R version 3.1.0)
So I ran
> install.packages('gsl',type = 'source')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/gsl_1.9-10.tar.gz'
Content type 'application/x-gzip' length 342803 bytes (334 Kb)
opened URL
==================================================
downloaded 334 Kb
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
checking for gsl-config... no
configure: error: gsl-config not found, is GSL installed?
ERROR: configuration failed for package ‘gsl’
* removing ‘/Users/myusername/Library/R/3.1/library/gsl’
Warning in install.packages :
installation of package ‘gsl’ had non-zero exit status
No GSL install. D'oh! So I install GSL via Homebrew:
~ brew install gsl
==> Downloading http://ftpmirror.gnu.org/gsl/gsl-1.15.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gsl/1.15
==> make
==> make install
/usr/local/Cellar/gsl/1.15: 239 files, 6.7M, built in 101 seconds
Try to install the R package again:
> install.packages('gsl',type = 'source')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/gsl_1.9-10.tar.gz'
Content type 'application/x-gzip' length 342803 bytes (334 Kb)
opened URL
==================================================
downloaded 334 Kb
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
checking for gsl-config... /usr/local/bin/gsl-config
checking if GSL version >= 1.12... checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
configure: error: Need GSL version >= 1.12
ERROR: configuration failed for package ‘gsl’
* removing ‘/Users/myusername/Library/R/3.1/library/gsl’
Warning in install.packages :
installation of package ‘gsl’ had non-zero exit status
I'm obviously going about this the wrong way but am unsure about where exactly the problem lies.
I was able to get things working (OS X Yosemite 10.10, R 3.1.1, gsl 1.16, gsl R package 1.9-10) with standard brew-installed R and gsl by manually prefixing CFLAGS and LDFLAGS with the output from gsl-config --cflags and gsl-config --libs respectively.
The following:
CFLAGS="-I/usr/local/opt/gsl/include" LDFLAGS="-L/usr/local/opt/gsl/lib -lgsl -lgslcblas" R
...
> install.packages("gsl")
worked for me.
Note that gsl-config lists the direct path to my Cellar, the paths above are brew symlinks.
For Mac, just run:
brew install gsl
then install the package in r
I finally got this to work though I'm not sure which parts of the following are absolutely essential. Here's a step-by-step list of instructions:
(steps in parentheses may be optional. Perhaps the whole thing works with homebrew)
(download the latest version of the GSL from http://ftp.gnu.org/gnu/gsl/ (as of this writing the file to get is gsl-1.16.tar.gz))
(open up a terminal window, untar the file, cd into the directory and then run ./configure, make and make install)
download the sources to the R package from http://cran.r-project.org/web/packages/gsl/index.html
open up a terminal window and run launchctl setenv PATH "/usr/local/bin:$PATH"
in the same terminal window, build the R package (I couldn't get this to work from within R) by untar'ing the file just downloaded, cding into the directory and then running R CMD build ./gsl and R CMD INSTALL gsl_1.9-10.tar.gz
Note to self: On Debian, to fix
checking for gsl-config... no
configure: error: gsl-config not found, is GSL installed?
I needed to
sudo apt-get install libgsl-dev
Note that the package name on Debian is not gsl-devel as elsewhere. Sigh.
I believe that others will find your steps successful and I think they do need to be done in that order. The build of gsl from source does need to be done after adding the homebrew default directory to the path. If you had used the binary, it was built on a CRAN machine that was able to find the (external) GSL package in the expected directy (which is not the default for homebreww installations. You might have succeeded with `install.packages('gsl_1.9-10.tar.gz', repo=NULL, type="source") if the source package were in your working directory (or add the full path/name as the first argument.) Just as with using Terminal, if you click-hold-drag a file to the R console, you will get a text entry of the full path/name.
gsl-config in included with the gsl-devel package, try installing that. After that it should work
On OS X Mavericks at least, after installing gsl via brew install gsl, the gsl-config --prefix yields /usr/local/Cellar/gsl/1.16. However, many applications/libraries like gsll for Common Lisp (in my case) expect /usr/local/Cellar/gsl/1.16/lib instead. In my case, the super lazy (long-term unacceptable) solution was just to symlink the libs from /usr/local/Cellar/gsl/1.16/lib into /usr/local/Cellar/gsl/1.16 and all was well. Hope this helps.

Resources