I have problem in installing plyr R package, and got the following error:
Installing package into '/home/mousavian/R/x86_64-pc-linux-gnu-library/3.2'
(as 'lib' is unspecified)
* installing *source* package 'plyr' ...
** package 'plyr' successfully unpacked and MD5 sums checked
** libs
g++ -I/share/apps/R/lib64/R/include -DNDEBUG -I/usr/local/include -I"/home/mousavian/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include" -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o
gcc -I/share/apps/R/lib64/R/include -DNDEBUG -I/usr/local/include -I"/home/mousavian/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include" -fpic -g -O2 -c loop_apply.c -o loop_apply.o
loop_apply.c: In function 'loop_apply':
loop_apply.c:15:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
for(int i = 0; i < n1; i++) {
^
loop_apply.c:15:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
make: *** [loop_apply.o] Error 1
ERROR: compilation failed for package 'plyr'
* removing '/home/mousavian/R/x86_64-pc-linux-gnu-library/3.2/plyr'
Warning message:
In install.packages("R packages/plyr_1.8.3.tar.gz", repos = NULL) :
installation of package 'R packages/plyr_1.8.3.tar.gz' had non-zero exit status
How can I use -std=c99 option when try to install R packages from the source by install.packages command?
Thanks
Try C11 First
The compiler error tells you to choose either C99 or C11. So unless you're knowingly compiling legacy code, try C11 first. You can always then try the legacy C99 if that doesn't work.
Use withr::with_makevars
Editing individual package Makevars or coordinating global changes to your include/lib directories for every package that doesn't directly compile from source is not a happy strategy for the future. Don't do that! A great alternative to editing your R's make configuration is to use withr::with_makevars to manipulate the Makevars only for the installation command:
library(withr)
with_makevars(c(PKG_CFLAGS = "-std=c11"),
install.packages("plyr", repos = NULL, type = "source"),
assignment = "+=")
Plus, you likely already have withr installed since it's a devtools dependency.
If not already existing, create a directory in your $HOME (/home/mousavian/.R in your case). Inside, create a Makevars file (no extension). Edit this file with your favorite editor and write:
CC = gcc -std=c99
Then, save it and after starting R, simply run
install.packages("plyr", dependencies = TRUE)
It should compile with gcc -std=c99.
The default /etc/R/Makeconf includes CC = gcc -std=gnu99 (R 3.3.2 and probably most or all other recent versions, although I think the in-progress development version jumps up into the 21st century)
The accepted answer may well work, but is not the R default. Setting CC=gcc with no other options would drop this default, and this another reason for getting this error. Best to leave defaults alone unless you know what you're doing.
As an addendum, to possibly save someone a few minutes: I ran into a similar issue after an R update to 3.3.2 on an Rstudio server (that I have no control over), but with g++. Compiler options for g++ may be added to Makevars like this:
CXX1XSTD = -std=gnu++11
(the package I needed to compile required gnu++11)
Related
I know this question has been asked many times, but my case is very special: I am using a Linux cluster where I do not have root but could only use commands like "module load gcc" "module load mkl" "module load R3.3/mkl" and so on to load libraries.
Recently I tried installing mxnet on my account on that cluster, after that everything seems to work, but then I switched from R3.2 to R3.2 by using "module load R3.3/mkl" instead of "module load R3.2/mkl", but now when I try to load R packages like stringi, it said
library(stringi),
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.3/stringi/libs/x
86_64/stringi.so':
/usr/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/hpc/pr74ze/ru37wof2/R/x86
_64-pc-linux-gnu-library/3.3/stringi/libs/x86_64/stringi.so)
Error: package or namespace load failed for ‘stringi’
I remember that I have tried to load gsl before
module list
Currently Loaded Modulefiles:
1) admin/1.0 3) intel/16.0 5) mpi.intel/5.1 7) R/3.3mkl 9) git/latest 11) gsl/1.16
2) tempdir/1.0 4) mkl/11.3 6) lrz/default 8) nano/2.2 10) gcc/4.9
if I run the following
echo $LD_LIBRARY_PATH
/usr/lib64:/lrz/mnt/sys.x86_64/compilers/java/jdk1.7.0_51/jre/lib/amd64/server:/usr/lib64:/lrz/mnt/sys.x86
_64/compilers/java/jdk1.7.0_51/jre/lib/amd64/server:/lrz/sys/libraries/gsl/1.16/lib:/lrz/sys/compilers/gcc
/4.9.3/lib64:/lrz/sys/compilers/gcc/4.9.3/lib:/lrz/sys/applications/R/3.3.1_MKL/lib64/R/lib/x86_64:/lrz/sy
s/intel/impi/5.1.3.181/lib64:/lrz/sys/intel/studio2016_u4/compilers_and_libraries_2016.4.258/linux/mkl/lib
/intel64:/lrz/sys/intel/studio2016_u4/debugger_2016/libipt/intel64/lib:/lrz/sys/intel/studio2016_u4/compil
ers_and_libraries_2016.4.258/linux/compiler/lib/intel64
If I try to install the RcppZiggurat
* installing *source* package ‘RcppZiggurat’ ...
** package ‘RcppZiggurat’ successfully unpacked and MD5 sums checked
** libs
*** arch - x86_64
icpc -I/lrz/sys/applications/R/3.3.1_MKL/lib64/R/include -I/lrz/sys/applications/R/3.3.1_MKL/lib64/R/include/x86_64 -DNDEBUG -I. -I../inst/include -I/usr/local/include -I"/home/hpc/pr74ze/ru37wof2/R/x86_64-pc-lin
ux-gnu-library/3.3/Rcpp/include" -I"/home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.3/RcppGSL/include" -fpic -O3 -c RcppExports.cpp -o RcppExports.o
In file included from /home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.3/RcppGSL/include/RcppGSL.h(25),
from RcppExports.cpp(4):
/home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.3/RcppGSL/include/RcppGSLForward.h(26): catastrophic error: cannot open source file "gsl/gsl_vector.h"
#include <gsl/gsl_vector.h>
^
compilation aborted for RcppExports.cpp (code 4)
But how should I proceed to find out where the problem is?
Note the 3.3 hiding inside of /home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.3/stringi/libs/x 86_64/stringi.so -- you probably built that under 3.2 so it sits below /home/hpc/pr74ze/ru37wof2/R/x86_64-pc-linux-gnu-library/3.2.
You can overcome this by setting your own .libPaths(), either directly or via environment variables -- you may want something like ~/R/library. See help(Startup) for details.
I'm running R 3.6.1 in an Anaconda environment (it won't let me upgrade to v4) and trying to install semPlot to accompany lavaan which installed fine. Here are the packages I've installed:
library(psych) # for Chronbach's alpha calculation
library(psychTools)
library(lavaan)
library(knitr)
library(tidyverse)
library(haven)
library(labelled)
library(kableExtra)
library(survey)
library(srvyr)
library(scales)
I've tried many different ways to install semPlot, the latest was directly from the github repository: SachaEpskamp/semPlot, which one person on stackoverflow said worked for them. After about 10,000 lines of warnings and errors scrolling across my console so fast I couldn't track much of it, this latest attempt produced this at the end:
The downloaded source packages are in
‘/private/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T/RtmpvagRhg/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
✓ checking for file ‘/private/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T/RtmpvagRhg/remotes164e53982f159/SachaEpskamp-semPlot-a2ee9df/DESCRIPTION’ ...
─ preparing ‘semPlot’:
✓ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘semPlot_1.1.4.tar.gz’
ERROR: dependency ‘OpenMx’ is not available for package ‘semPlot’
* removing ‘/Users/sjgenco/opt/anaconda3/envs/r_env/lib/R/library/semPlot’
Warning messages:
1: In i.p(...) : installation of package ‘OpenMx’ had non-zero exit status
2: In i.p(...) :
installation of package ‘/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T//RtmpvagRhg/file164e543b3278e/semPlot_1.1.4.tar.gz’ had non-zero exit status
I don't know if OpenMx is the culprit or if OpenMX and semPlot may be suffering from the same problem, but I get the same sort of result when I try to install it ... thousands of lines (and about 20 minutes of fruitless runtime) before it just peters out, not with any kind of error, just a "nonzero exit status".
I've read lots of similar questions here on SO, but most have some dependent package not being found, like glasso or XML a missing fortran compiler, but I have no references like that in my output and I have all those packages installed anyway. I just have reams of output like this (this is from a failed OpenMx installation attempt:
In file included from povRAM.cpp:2:
In file included from ./omxExpectation.h:32:
In file included from ./omxDefines.h:21:
In file included from /Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp.h:27:
In file included from /Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/RcppCommon.h:120:
In file included from /Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/proxy.h:22:
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/NamesProxy.h:32:21: warning: definition of implicit copy constructor for 'NamesProxy' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
NamesProxy& operator=(const NamesProxy& rhs) {
^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/NamesProxy.h:83:16: note: in implicit copy constructor for 'Rcpp::NamesProxyPolicy<Rcpp::Vector<19, PreserveStorage> >::NamesProxy' first required here
return NamesProxy( static_cast<CLASS&>(*this) ) ;
^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/api/meat/module/Module.h:35:11: note: in instantiation of member function 'Rcpp::NamesProxyPolicy<Rcpp::Vector<19, PreserveStorage> >::names' requested here
info.names() = names ;
^
In file included from povRAM.cpp:3:
In file included from ./path.h:6:
./polynomial.h:26:2: warning: definition of implicit copy assignment operator for 'Monomial<double>' is deprecated because it has a user-declared copy constructor [-Wdeprecated-copy]
Monomial(const Monomial<F> &from) { coeff = from.coeff; exponent = from.exponent; }
^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/bin/../include/c++/v1/__tree:1691:39: note: in implicit copy assignment operator for 'Monomial<double>' first required here
__cache.__get()->__value_ = *__first;
^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/bin/../include/c++/v1/__tree:1648:9: note: in instantiation of function template specialization 'std::__1::__tree<Monomial<double>, std::__1::less<Monomial<double> >, std::__1::allocator<Monomial<double> > >::__assign_multi<std::__1::__tree_const_iterator<Monomial<double>, std::__1::__tree_node<Monomial<double>, void *> *, long> >' requested here
__assign_multi(__t.begin(), __t.end());
^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/bin/../include/c++/v1/set:538:21: note: in instantiation of member function 'std::__1::__tree<Monomial<double>, std::__1::less<Monomial<double> >, std::__1::allocator<Monomial<double> > >::operator=' requested here
__tree_ = __s.__tree_;
^
./polynomial.h:183:13: note: in instantiation of member function 'std::__1::set<Monomial<double>, std::__1::less<Monomial<double> >, std::__1::allocator<Monomial<double> > >::operator=' requested here
monomials = erg.monomials;
^
povRAM.cpp:299:16: note: in instantiation of member function 'Polynomial<double>::operator+=' requested here
polyRep[nn] += term;
^
95 warnings and 7 errors generated.
make: *** [/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/etc/Makeconf:175: povRAM.o] Error 1
ERROR: compilation failed for package ‘OpenMx’
* removing ‘/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/OpenMx’
Warning in install.packages :
installation of package ‘OpenMx’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T/Rtmp8fpYnY/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
A warning that comes up again and again in all these outputs is this:
warning: definition of implicit copy constructor ...
as in:
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/NamesProxy.h:32:21: warning: definition of implicit copy constructor for 'NamesProxy' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
NamesProxy& operator=(const NamesProxy& rhs) {
^
or this
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/AttributeProxy.h:33:25: warning: definition of implicit copy constructor for 'AttributeProxy' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
AttributeProxy& operator=(const AttributeProxy& rhs){
^
or this
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/RcppEigen/include/Eigen/src/SparseCore/SparsePermutation.h:162:1: note: candidate template ignored: could not match 'InverseImpl' against 'Transpose'
operator*(const SparseMatrixBase<SparseDerived>& matrix, const InverseImpl<PermutationType, PermutationStorage>& tperm)
^
povRAM.cpp:157:24: error: use of undeclared identifier 'curProd'
if (tx == 1) prev = curProd.nonZeros();
^
This is just a big mess and I have no idea what's happening, why, or what to do about it. Any thoughts?
Your problems are likely caused by running R through Anaconda. Following these steps I successfully install OpenMX and semPlot without error on macOS 11.4 / Rv4.0, but you'll have to try it to find out if they will work on 'conda' R3.6.3.
Install xcode from the app store (instructions for installing xcode) then install/reinstall the xcode command line tools from the terminal:
# To delete an existing command line tools installation:
sudo rm -rf /Library/Developer/CommandLineTools
# To install the command line tools
sudo xcode-select --install
Install gcc & llvm via Homebrew (instructions for installing Homebrew) or, if you already have gcc and llvm installed, skip to step 3.
# WARNING: This can take several hours
brew install gcc
brew install llvm
If you already have gcc & llvm installed via Homebrew:
brew cleanup
brew update
brew upgrade
brew reinstall gcc
brew reinstall llvm
Link some headers into /usr/local/include
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
# You can ignore warnings like this:
#ln: /usr/local/include//tcl.h: File exists
#ln: /usr/local/include//tclDecls.h: File exists
#ln: /usr/local/include//tclPlatDecls.h: File exists
#ln: /usr/local/include//tclTomMath.h: File exists
#ln: /usr/local/include//tclTomMathDecls.h: File exists
#ln: /usr/local/include//tk.h: File exists
#ln: /usr/local/include//tkDecls.h: File exists
#ln: /usr/local/include//tkPlatDecls.h: File exists
Check your version of gfortran (cd /usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/; ls) then edit your ~/.R/Makevars file (if you don't have a file called Makevars in your ~/.R/ directory, or the 'conda' R equivalent directory, create it) and include only these lines:
LOC = /usr/local/gfortran
CC=$(LOC)/bin/gcc -fopenmp
CXX=$(LOC)/bin/g++ -fopenmp
CXX11 = $(LOC)/bin/g++ -fopenmp
CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib
CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
# (check that the version of gfortran - in this case 10.2.0 - matches the version specified in FLIBS)
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/10.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CXX1X=/usr/local/gfortran/bin/g++
CXX98=/usr/local/gfortran/bin/g++
CXX11=/usr/local/gfortran/bin/g++
CXX14=/usr/local/gfortran/bin/g++
CXX17=/usr/local/gfortran/bin/g++
Open R and install the packages (when asked, compile from source = "Yes"):
install.packages("qgraph")
install.packages("OpenMx")
devtools::install_github("SachaEpskamp/semPlot")
Then, hopefully, things will load as they are supposed to.
Thank you for this detailed advice. First I tried to fix it inside my Anaconda environment by running the conda forge installation in my r_env from the terminal. It installed, but it also managed to break my RStudio installation so that wouldn't open anymore. OK, lesson learned. I deleted my whole r_env in Anaconda and proceeded to follow #MrFlick's advice to install clean new versions of R and RStudio from their official download sites. When I opened my fresh RStudio app, I was able to install semPlot, which installed its dependency OpenMx without a hitch. Back in business.
I'm just starting to experiment with the Rcpp package, so please be patient with me.
I read the Rcpp vignettes and I've tried a few given examples in the Rcpp documentation. Now, I thought I'd start by wrapping some functions from the GLFW libray, a library written in C.
So I thought I'd start with the function glfwInit. I wrote this simple cpp source file in a package named pixel to wrap it under the name glfw_init:
#include <Rcpp.h>
#include <GLFW/glfw3.h>
using namespace Rcpp;
//' #export
// [[Rcpp::export]]
int glfw_init() {
return(glfwInit());
}
I am working in RStudio, using the usual rinse and repeat cycle of generating documentation and building the package (I am using roxygen2).
The function is exported to R and the user space, so if I type glfw_init in the R console I get:
function() {
.Call('_pixel_glfw_init', PACKAGE = 'pixel')
}
<bytecode: 0x5558ece6f398>
<environment: namespace:pixel>
But if I try to run it with glfw_init() and get the error:
Error in .Call("_pixel_glfw_init", PACKAGE = "pixel") :
"_pixel_glfw_init" not available for .Call() for package "pixel"
I feel I'm missing some minor setup detail for this to work... Any help is appreciated!
P.S.: As per Konrad's comment I am posting here the output I am getting in RStudio's build pane:
==> Rcpp::compileAttributes()
* Updated R/RcppExports.R
==> R CMD INSTALL --no-multiarch --with-keep.source pixel
g++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG -I"/home/rmagno/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c glfw.cpp -o glfw.o
* installing to library ‘/home/rmagno/R/x86_64-pc-linux-gnu-library/3.6’
* installing *source* package ‘pixel’ ...
** using staged installation
** libs
g++ -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -o pixel.so RcppExports.o glfw.o -L/usr/lib64/R/lib -lR
installing to /home/rmagno/R/x86_64-pc-linux-gnu-library/3.6/00LOCK-pixel/00new/pixel/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (pixel)
P.S.2: Here's my NAMESPACE:
# Generated by roxygen2: do not edit by hand
export(coords_rectangle)
export(coords_rectangular_lattice)
export(coords_segment)
export(coords_square)
export(display_matrix_int)
export(glfw_init)
export(lgl_matrix_to_coords_grid_segment)
export(lgl_matrix_to_coords_segment)
export(palette_for_quads)
P.S.3: After creating a new file R/pixel.R:
#' #useDynLib pixel, .registration = TRUE
#' #importFrom Rcpp sourceCpp
NULL
I get now this error when I try to generate the documentation:
==> Rcpp::compileAttributes()
* Updated R/RcppExports.R
==> devtools::document(roclets = c('rd', 'collate', 'namespace'))
Updating pixel documentation
Loading pixel
Error in dyn.load(dllfile) :
unable to load shared object '/home/rmagno/sci/code/R/pkg/pixel/src/pixel.so':
/home/rmagno/sci/code/R/pkg/pixel/src/pixel.so: undefined symbol: glfwInit
Calls: suppressPackageStartupMessages ... <Anonymous> -> load_dll -> library.dynam2 -> dyn.load
Execution halted
Exited with status 1.
The new error indicates that you didn’t link the C++ code against the GLFW library. You need to provide a src/Makevars file that adds the library to the PKG_LIBS. See Using Makevars in the Writing R Extensions manual.
I am trying to build and check a package with some Fortran code in it under Windows 10
with R 3.4.0 updating some code previously in R 2.8.
I am doing this in three steps in the command window:
>R CMD build src
[...]
* checking DESCRIPTION meta-information ... OK
So I assume everything is ok with the DESCRIPTION file
then:
>R CMD check --no-examples --no-tests src
I get among other stuff:
* checking for file 'src/DESCRIPTION' ... OK
A bit further it gets wrong at
* checking whether package 'pckgname' can be installed
Looking at the log inside the file /src.Rcheck/00install.out, I read:
Error in .get_package_metadata(dir, FALSE) :
Files 'DESCRIPTION' and 'DESCRIPTION.in' are missing.
ERROR: installing Rd objects failed for package 'samara'
I have copied and pasted the DESCRIPTION file pretty much everywhere it made sense, including the top level directory and the \src directory or in those directory alone in some other trials, with always the same result.
This is strange because sometimes the DESCRIPTION file is recognized, sometimes it is not
There is only one similar post treating this subject:
R package building error
the author seems to have solved his problem but he doesn't know how.
Does anybody know what happened?
Following some requests, here is the content of the files 00check.log and 00install.out:
00check.log
C:\Users\username\Documents\PCKGNAME\SRC_5.0.2E\pckgname>R CMD check --no- examples --no-tests src
* using log directory 'C:/Users/username/Documents/PCKGNAME/SRC_5.0.2E/pckgname/src.Rcheck'
* using R version 3.4.0 (2017-04-21)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* using options '--no-examples --no-tests'
* checking for file 'src/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'pckgname' version '5.0.2.5'
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... NOTE
Found the following apparent object files/libraries:
src-x64/FortPrg1.o src-x64/FortPrg2.o src-x64/FortPrg3.o
Object files/libraries should not be included in a source package.
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... NOTE
Found the following hidden files and directories:
R/.Rhistory
These were most likely included in error. See section 'Package
structure' in the 'Writing R Extensions' manual.
* checking for portable file names ... OK
* checking whether package 'pckgname' can be installed ... ERROR
Installation failed.
See 'C:/Users/username/Documents/PCKGNAME/SRC_5.0.2E/pckgname/src.Rcheck/00install.out' for details.
* DONE
Status: 1 ERROR, 2 NOTEs
In Prompt, there is this information in addition to what appeared before:
* checking whether package 'pckgname' can be installed ...
Warning: l'exécution de la commande '"C:/PROGRA~1/R/R-34~1.0/bin/x64/Rcmd.exe"
INSTALL -l "C:/Users/username/Documents/PCKGNAME/SRC_5.0.2E/pckgname/src.Rcheck" --no-html
"C:\Users\username\DOCUME~1\PCKGNAME\SRC_30~1.7E\pckgname\src"' renvoie un statut 1
Now in the file 00install.out:
* installing *source* package 'pckgname' ...
** libs
*** arch - i386
c:/Rtools/mingw_32/bin/gfortran -O3 -mtune=core2 -c FortPrg1.f90 -o FortPrg1.o
c:/Rtools/mingw_32/bin/gfortran -O3 -mtune=core2 -c FortPrg2.f90 -o FortPrg2.o
c:/Rtools/mingw_32/bin/gfortran -O3 -mtune=core2 -c FortPrg3.f90 -o FortPrg3.o
c:/Rtools/mingw_32/bin/gfortran -shared -s -static-libgcc -o pckgname.dll tmp.def FortPrg1.o FortPrg2.o FortPrg3.o -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-34~1.0/bin/i386 -lR
installing to C:/Users/username/Documents/PCKGNAME/SRC_5.0.2E/pckgname/src.Rcheck/pckgname/libs/i386
*** arch - x64
c:/Rtools/mingw_64/bin/gfortran -O2 -mtune=core2 -c FortPrg1.f90 -o FortPrg1.o
c:/Rtools/mingw_64/bin/gfortran -O2 -mtune=core2 -c FortPrg2.f90 -o FortPrg2.o
c:/Rtools/mingw_64/bin/gfortran -O2 -mtune=core2 -c FortPrg3.f90 -o FortPrg3.o
c:/Rtools/mingw_64/bin/gfortran -shared -s -static-libgcc -o pckgname.dll tmp.def FortPrg1.o FortPrg2.o FortPrg3.o -Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-34~1.0/bin/x64 -lR
installing to C:/Users/username/Documents/PCKGNAME/SRC_5.0.2E/pckgname/src.Rcheck/pckgname/libs/x64
** R
** demo
** preparing package for lazy loading
Warning: package 'survival' was built under R version 3.4.4
Warning: package 'boot' was built under R version 3.4.4
Warning: package 'xlsx' was built under R version 3.4.4
Warning: package 'ggplot2' was built under R version 3.4.4
Warning: package 'GGally' was built under R version 3.4.4
[1] "Chargement de gdata ..."
[1] "Chargement de survival ..."
[1] "Chargement de boot ..."
[1] "Chargement de tcltk ..."
[1] "Chargement de xlsx ..."
---------------------------------------------
Package PCKGNAME genere le ven. sept. 28 17:14:21 2018
---------------------------------------------
Librairie Pckgname V5.0.2E Chargee
** help
No man pages found in package 'pckgname'
Error in .get_package_metadata(dir, FALSE) :
Files 'DESCRIPTION' and 'DESCRIPTION.in' are missing.
ERROR: installing Rd objects failed for package 'pckgname'
* removing 'C:/Users/username/Documents/PCKGNAME/SRC_5.0.2E/pckgname/src.Rcheck/pckgname'
Usually you would store a package named samara in a directory of the same name. You appear to have it in src. That should work, but I wouldn't be surprised if something in the check code implicitly assumes you were following the usual convention.
The other thing that is usually done is that you create a source tarball of the package and check that. That is, you run R CMD check on the output of R CMD build, not on the input. Again, what you are doing should mostly work (though not perfectly in this case; tarball contents typically are not identical to source directories), but perhaps these two nonstandard ways of working are causing your problems.
With the help of user2554330, I solved the problem.
I did the following things:
-I reorganized into pckgname/R and pckgname/src
(instead of pckgname/src/R and pckgname/src/src previously )
-I used R Studio. First I created a new project (create a new package) with RStudio and devtools: File>Create new project>R Package using devtools. And I put my files there
-I built and checked exclusively with the Rstudio interface
I'm trying to install the CausalImpact package and failing due to a dependency on bsts.
I've tried to install bsts without success, and looking at the results I see what I think is a failure on a dependency for Boom:
install.packages("bsts", lib="C:/R/win-library/3.3")
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘bsts’
Do you want to attempt to install these from sources?
y/n: y
installing the source package ‘bsts’
trying URL 'https://cran.rstudio.com/src/contrib/bsts_0.6.3.tar.gz'
Content type 'application/x-gzip' length 148815 bytes (145 KB)
downloaded 145 KB
* installing *source* package 'bsts' ...
** package 'bsts' successfully unpacked and MD5 sums checked
** libs
*** arch - i386
c:/Rtools/mingw_32/bin/g++ -std=c++0x -I"C:/PROGRA~1/R/R-33~1.0/include" -DNDEBUG -I`C:/PROGRA~1/R/R-33~1.0/bin/Rscript -e "cat(system.file(package='Boom'))"`/include -DNO_BOOST_THREADS -DNO_BOOST_FILESYSTEM -DADD_ -DR_NO_REMAP -DRLANGUAGE -I"C:/Users/Firstname Lastname/Documents/R/win-library/3.3/Boom/include" -I"C:/Users/Firstname Lastname/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O2 -Wall -mtune=core2 -c aggregate_time_series.cc -o aggregate_time_series.o
g++.exe: error: Lastname/Documents/R/win-library/3.3/Boom/include: No such file or directory
What I assume is that g++ is getting upset because R has put the library in a subfolder of C:Users/Firstname Lastname, and it's not liking the space in my name.
I tried setting the R_LIBS_USER environment variable to C:/R/win-library/3.3 to eliminate this problem with a space in the path, but with no success - even after a full restart of the computer, the error repeats - it's still going to the C:/Users/Firstname Lastname/Documents/R/win-library/3.3 directory.
I'm using RStudio 0.99.896 with R 3.3.0 on Windows 10, if that makes any difference
As suggested in this related question if you don't necessarily need the latest version of bsts you can still install version 0.6.2 on Windows, and that will let you install CausalImpact:
install.packages("https://cran.r-project.org/bin/windows/contrib/3.2/bsts_0.6.2.zip",
repos = NULL, type = "local")
library(devtools)
devtools::install_github("google/CausalImpact")
works on Win 10, R 3.3.0