Installing R packages - r

When I have tried to install some R packages such as Rgraphviz, I get the following error:
install.packages("Rgraphviz_2.12.0.tar.gz",repos=NULL,type="source")
* installing *source* package 'Rgraphviz' ...
**********************************************
WARNING: this package has a configure script
It probably needs manual configuration
**********************************************
** libs
gcc -m32 -I"C:/PROGRA~1/R/R-31~1.2/include" -DNDEBUG -
I"d:/RCompile/CRANpkg/extralibs64/local/include" -
Ilibwin/i386/include/graphviz -DHAVE_STDBOOL_H=1 -DHAVE_BOOL=1 -
DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=28 -DGRAPHVIZ_STATIC -O3 -Wall -
std=gnu99 -mtune=core2 -c LL_funcs.c -o LL_funcs.o
gcc: unrecognized option `-std=gnu99'
d:\RCompile\CRANpkg\extralibs64\local\include\.: Permission denied
make.exe: *** [LL_funcs.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/R/R-
31~1.2/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-31~1.2/share/make/winshlib.mk"
SHLIB="Rgraphviz.dll" OBJECTS="LL_funcs.o Rgraphviz.o RgraphvizInit.o
agopen.o agread.o agwrite.o bezier.o buildEdgeList.o buildNodeList.o
doLayout.o graphvizVersion.o init.o"' had status 2
ERROR: compilation failed for package 'Rgraphviz'
* removing 'C:/Program Files/R/R-3.1.2/library/Rgraphviz'
Warning messages:
1: running command '"C:/PROGRA~1/R/R-31~1.2/bin/i386/R" CMD INSTALL -l
"C:\Program Files\R\R-3.1.2\library" "Rgraphviz_2.12.0.tar.gz"' had status 1
2: In install.packages("Rgraphviz_2.12.0.tar.gz", repos = NULL, type =
"source") :
installation of package ‘Rgraphviz_2.12.0.tar.gz’ had non-zero exit status
I am mostly appreciate any comment.

The first thing to do is take care of the
d:\RCompile\CRANpkg\extralibs64\local\include\.: Permission denied
error. Check file permissions on that directory; does it belong to Administrator? Make sure you have read access to it.

Related

R package build failing on Windows machines (AppVeyor) due to missing GSL - GNU Scientific Library

I am developing an R package called DescObs (https://github.com/MaaniBeigy/DescObs). It imports conf.limits.nct function from MBESS, which itself depends on another package called gsl. It shows no problems at all for R CMD check and the installation of DescObs on Linux machines assessed by Travis continuous integration platform (https://travis-ci.org/MaaniBeigy/DescObs). However, AppVeyor fails:
** libs
*** arch - i386
C:/Rtools/mingw_32/bin/gcc -I"c:/R/include" -DNDEBUG -I/include -O3 -Wall -std=gnu99 -mtune=generic -c airy.c -o airy.o
airy.c:1:29: fatal error: gsl/gsl_sf_airy.h: No such file or directory
#include <gsl/gsl_sf_airy.h>
^
compilation terminated.
make: *** [c:/R/etc/i386/Makeconf:208: airy.o] Error 1
ERROR: compilation failed for package 'gsl'
* removing 'c:/RLibrary/gsl'
Error in i.p(...) :
(converted from warning) installation of package 'gsl' had non-zero exit status
Calls: <Anonymous> ... with_rprofile_user -> with_envvar -> force -> force -> i.p
Execution halted
Command exited with code 1
I also tried the solution recommended in Building an R package that uses the GSL on Windows but it did not help. I also compiled it using mingw-w64 and gcc-4.6.3, which both showed the same error.
Moreover, I tried to install by - cmd: vcpkg install gsl:x64-windows, but did show the same error. Here, you can see my appveyor.yml.
Do you have any ideas?
Fortunately, my previous appveyor.yml could finally build it:
install:
- ps: Bootstrap
- cmd: git submodule update --init --recursive
- cmd: git clone https://github.com/CxxTest/cxxtest
- cmd: cd c:\tools\vcpkg
- cmd: vcpkg integrate install
- cmd: vcpkg install gsl:x64-windows
- cmd: vcpkg install fftw3:x64-windows
- cmd: cd "%APPVEYOR_BUILD_FOLDER%"
environment:
global:
USE_RTOOLS: true
NOT_CRAN: true
_R_CHECK_FORCE_SUGGESTS: true
_R_CHECK_CRAN_INCOMING_: true
#R_CHECK_ARGS: "--run-dontrun"
matrix:
- R_VERSION: devel
R_ARCH: x64
GCC_PATH: gcc-4.6.3
I do not know the exact reason, but I am glad it works.
edit: I faced the problem again in another package. This line by Owen McDonnell image: previous visual studio 2015 could solve the problem. Refer to cvcqv package for the full appveyor.yml.
I came to this thread because I faced what I think is a very similar situation when I tried to update the package gsl:
installing source package 'gsl' ...
** package 'gsl' successfully unpacked and MD5 sums checked
** using staged installation
********************************************** WARNING: this
package has a configure script
It probably needs manual configuration **********************************************
** libs "C:/rtools40/mingw64/bin/"gcc -I"C:/PROGRA~1/R/R-4.1.1/include" -DNDEBUG -I/include -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c airy.c -o airy.o airy.c:1:10: fatal error: gsl/gsl_sf_airy.h: No such file or
directory #include <gsl/gsl_sf_airy.h>
^~~~~~~~~~~~~~~~~~~ compilation terminated. make: *** [C:/PROGRA~1/R/R-4.1.1/etc/x64/Makeconf:238: airy.o] Error 1 ERROR:
compilation failed for package 'gsl'
removing 'C:/Users/shima/OneDrive/Documents/R/win-library/4.1/gsl'
restoring previous 'C:/Users/shima/OneDrive/Documents/R/win-library/4.1/gsl' Warning in
install.packages : installation of package ‘gsl’ had non-zero exit
status
This thread helped me find the solution, a warm thank you, along with this discussion and this one
For those of you on Windows, using Rtools, here are my steps to solve this issue, i.e. not being able to update gsl package in R under windows:
start Rtools Bash (found in apps, Rtools 4.0 in the Windows menu)
Run pacman -S mingw-w64-x86_64-gsl and confirm with yes (y)
I don't think it's relevant, but i ran pacman -Syu just before to update my Rtools and throwing the command pacman -Sl gave me the correct name of the package for the pacman command in 2.
Updating gsl in Rstudio now leads to a clean
DONE (gsl)

Tell Rstudio to use mpif90 instead of gfortran

In order to learn how to create a R packages that uses Fortran I created a simple one to calculate Pi with a monte carlo simulation. Now I'm trying to make the Fortran code parallel with MPI.
When I add use MPI to my fortran code and click the Build and Reload buton on Rstudio I get the following error.
==> R CMD INSTALL --no-multiarch --with-keep.source MyPi
* installing to library ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2’
* installing *source* package ‘MyPi’ ...
gfortran -fpic -g -O2 -fstack-protector-strong -c Fpi.f90 -o Fpi.o
/usr/lib/R/etc/Makeconf:161: recipe for target 'Fpi.o' failed
** libs
Fpi.f90:2.4:
use mpi
1
Fatal Error: Can't open module file 'mpi.mod' for reading at (1): No such file or directory
make: *** [Fpi.o] Error 1
ERROR: compilation failed for package ‘MyPi’
* removing ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2/MyPi’
* restoring previous ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2/MyPi’
Exited with status 1.
I think the problem is that Rstudio is trying to compile using gfortran instead of mpi90. I'm able to follow this post to do a very basic hello world, but there you compile the code with mpif90 -fpic -shared -o test.so test.f90
How can I tell Rstudio to use mpif90 -fpic -shared instead of gfortran?
I added this to src/Makevars
FC=mpif90
This is what I get:
==> R CMD INSTALL --no-multiarch --with-keep.source MyPi
* installing to library ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2’
* installing *source* package ‘MyPi’ ...
gfortran -fpic -g -O2 -fstack-protector-strong -c Fpi.f90 -o Fpi.o
/usr/lib/R/etc/Makeconf:161: recipe for target 'Fpi.o' failed
** libs
Fpi.f90:2.4:
USE MPI
1
Fatal Error: Can't open module file 'mpi.mod' for reading at (1): No such file or directory
make: *** [Fpi.o] Error 1
ERROR: compilation failed for package ‘MyPi’
* removing ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2/MyPi’
* restoring previous ‘/home/ignacio/R/x86_64-pc-linux-gnu-library/3.2/MyPi’
Exited with status 1.
You just need to set the FC flag in your Makevars file to indicate the fortran compiler you wish to use.
FC=mpif90
EDIT - The above doesn't work if included locally in your package
The FC macro will be overwritten when specified within a package Makevars because the src/Makevars file is read before $RHOME/etc/Makeconf which overwrites the FC macro. In order to change the default compiler is to create a Makevars file in a .R/ directory in your $HOME directory.
Then just create the file with the same line as above. Restart R and try to compile again (this worked on my Ubuntu system).

install RMySQL on windows

I am trying to install the package RMYSQL on windows.
To do so i followed this tutorial : http://www.ahschulz.de/2013/07/23/installing-rmysql-under-windows/
But i am getting an error when i execute
install.packages(“RMySQL”, type = “source”)
In deed R returns me the following :
Installing package into ‘D:/Users/quentin/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/RMySQL_0.9-3.tar.gz'
Content type 'application/x-gzip' length 165363 bytes (161 Kb) opened URL
downloaded 161 Kb
* installing *source* package 'RMySQL' ...
** package 'RMySQL' correctement décompressé et sommes MD5 vérifiées
checking for $MYSQL_HOME... C:/Program Files (x86)/MySQL/mysql-5.6.19-win32
cygwin warning:
MS-DOS style path detected: C:/Program
Preferred POSIX equivalent is: /cygdrive/c/Program
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
test: Files: unknown operand
** libs
Avis : this package has a non-empty 'configure.win' file,
so building only the main architecture
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-31~1.0/etc/x64/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-31~1.0/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc -m64 -I"C:/PROGRA~1/R/R-31~1.0/include" -DNDEBUG -I"C:/Program Files (x86)/MySQL/mysql-5.6.19-win32"/include - I"d:/RCompile/CRANpkg/extralibs64/local/include"
-O2 -Wall -std=gnu99 -mtune=core2 -c
RS-DBI.c -o RS-DBI.o
RS-DBI.c: In function 'RS_na_set':
RS-DBI.c:1219:11: warning: variable 'c' set but not used [-Wunused-but-set-variable]
gcc -m64 -I"C:/PROGRA~1/R/R-31~1.0/include" -DNDEBUG -I"C:/Program Files (x86)/MySQL/mysql-5.6.19-win32"/include - I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall - std=gnu99 -mtune=core2 -c RS-MySQL.c -o RS-MySQL.o
RS-MySQL.c: In function 'RS_MySQL_fetch':
RS-MySQL.c:657:13: warning: variable 'fld_nullOk' set but not used [-Wunused-but-set- variable]
RS-MySQL.c: In function 'RS_DBI_invokeBeginGroup':
RS-MySQL.c:1137:30: warning: variable 'val' set but not used [-Wunused-but-set-variable]
RS-MySQL.c: In function 'RS_DBI_invokeNewRecord':
RS-MySQL.c:1158:20: warning: variable 'val' set but not used [-Wunused-but-set- variable]
RS-MySQL.c: In function 'RS_MySQL_dbApply':
RS-MySQL.c:1219:38: warning: variable 'fld_nullOk' set but not used [-Wunused-but-set- variable]
gcc -m64 -shared -s -static-libgcc -o RMySQL.dll tmp.def RS-DBI.o RS-MySQL.o C:/Program Files (x86)/MySQL/mysql-5.6.19-win32/bin/libmySQL.dll - Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-31~1.0/bin/x64 -lR
collect2: ld returned 5 exit status
aucune DLL n'a pas été créé
ERROR: compilation failed for package 'RMySQL'
* removing 'D:/Users/quentin/Documents/R/win-library/3.1/RMySQL'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-31~1.0/bin/x64/R" CMD INSTALL -l "D:\Users\quentin\Documents\R\win-library\3.1" D:\Users\quentin\AppData\Local\Temp\2\RtmpOwB1UH/downloaded_packages/RMySQL_0.9-3.tar.gz' had status 1
Warning in install.packages :
installation of package ‘RMySQL’ had non-zero exit status
The downloaded source packages are in
‘D:\Users\quentin\AppData\Local\Temp\2\RtmpOwB1UH\downloaded_packages’
I couldn't manage to fix this problem so if someone have an idea.
i tried all the steps from all the instructions i could get, but still got the same problems as you got.
I finallly solved accidently by follow this code:
install.packages('RMySQL')
instead of
install.packages(“RMySQL”, type = “source”)
I cannot explain the reason, but it truly works.
I solved it by installing from a .zip file not from .tar.gz.
Make sure your MYSQL_HOME environment variable is set correctly and libmysql.dll is copied to bin folder!!!
Run install.packages('RMySQL') then when the "Do you want to install from sources..." window pops up select No.
Then copy the downloaded binary packages location from console.
Go to Packages -> Install, paste the location into Package archive and click Install.

How to get Rcpp to work?

I cannot get Rcpp to work on Windows 8.1. When I run the following minimal example, I get an error.
> library(Rcpp)
> evalCpp("1 + 1")
g++ -m64 -I"C:/R/R-31~1.0/include" -DNDEBUG -I"C:/R/R-3.1.0/library/Rcpp/include" -
I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c file11dc2120723d.cpp -o
file11dc2120723d.o g++: not found make: *** [file11dc2120723d.o] Error 127 Warning message: running
command 'make -f "C:/R/R-31~1.0/etc/x64/Makeconf" -f "C:/R/R-31~1.0/share/make/winshlib.mk"
SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="sourceCpp_97232.dll" WIN=64 TCLBIN=64
OBJECTS="file11dc2120723d.o"' had status 2
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 1 occurred building shared library.
The two first entries in my path are:
PATH=c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;
R is installed in a directory C:\R\R-3.1.0
Rtools is in the directory C:\R\Rtools
Some additional information:
> library(devtools)
> find_rtools(T)
Scanning path...
ls : c:\Rtools\bin\ls.exe
Scanning registry...
Found c:/Rtools for 3.1
VERSION.txt
Rtools version 3.1.0.1942
[1] TRUE
> has_devel()
"C:/R/R-31~1.0/bin/x64/R" --vanilla CMD SHLIB foo.c
gcc -m64 -I"C:/R/R-31~1.0/include" -DNDEBUG -I"d:/RCompile/CRANpkg/extralibs64/local/include"
O2 -Wall -std=gnu99 -mtune=core2 -c foo.c -o foo.o
gcc: not found
make: *** [foo.o] Error 127
Warning message:
running command 'make -f "C:/R/R-31~1.0/etc/x64/Makeconf" -f "C:/R/R-31~1.0/share/make/winshlib.mk"
SHLIB="foo.dll" WIN=64 TCLBIN=64 OBJECTS="foo.o"' had status 2
Error: Command failed (1)
> system('g++ -v')
Warning message:
running command 'g++ -v' had status 127
Unsure if you have solved your problem but it appears you don't have gcc or g++ installed. For windows you can get these tools with MinGW.
Install MinGW which you can donwload from here. The homepage for information is here
Once you have it installed MinGW, you can open the 'MinGW Installation Manager' and install the bin and dev for 'mingw32-gcc-g++'.
You must then update your PATH environmental variable to include 'C:\MinGW\bin' and 'C:\MinGW\msys\1.0\bin'.
Restart your R session, couldn't hurt to also reinstall 'Rcpp', and tryrequire(Rcpp); evalCpp("1 + 1") again.
I had this problem while trying to call C-code directly. Switching from the function system() to system2() solved it immediately.
I got that fix by installing RTools and adding RBuildTools to the path:
Sys.setenv("PATH" = paste(Sys.getenv("PATH"),
"C:\\RBuildTools\\3.4\\bin",
"C:\\RBuildTools\\3.4\\mingw_32",
"C:\\RBuildTools\\3.4\\mingw_64", sep = ";"))
I don't understand these things clearly but #cdeterman solutions was not working for building my package while its example evalCpp("1 + 1") did.

error in R CMD build when editing c function in R package

I have modified a C function in the phmm package. Now I want to rebuild the package, but the following error occurred. How can I fix the error?
$ cd ~/Desktop/phmmw
$ R CMD build phmm
* checking for file ‘phmm/DESCRIPTION’ ... OK
* preparing ‘phmm’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* installing the package to re-build vignettes
-----------------------------------
* installing *source* package ‘phmm’ ...
** libs
*** arch - x86_64
gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include -fPIC -g -O2 -c arms.c -o arms.o
make: gcc-4.2: No such file or directory
make: *** [arms.o] Error 1
ERROR: compilation failed for package ‘phmm’
* removing ‘/private/var/folders/r0/9qv15p6j59j6jtfq775k6j380000gn/T/RtmpIPgvDE/Rinst48317ea7/phmm’
-----------------------------------
ERROR: package installation failed
Your R installation was configured with gcc in such a (suboptimal) was that the gcc-4.2 command was hardwired.
So you need to
either provide a command gcc-4.2, most commonly done via a symlink from gcc to gcc-4.2,
or change the R setting, presumably in the file $RHOME/etc/Makeconf where you need to look for CC
or change it on the fly by doing CC=gcc R CMD build phmm
You may need to modify more than just one CC setting, possibly CXX, LD and more. It may be as easy as always removing the -4.2 part.

Resources