R package DESCRIPTION - Remotes from Bioconductor should install binary - r

I am working on an R package (https://github.com/bgbrink/dropClust) and I was testing if it can be installed, since it depends on a number of packages both from CRAN and from Bioconductor. I specified the three dependencies from Bioconductor in the DESCRIPTION:
Remotes:
bioc::flowDensity,
bioc::SamSPECTRAL,
bioc::flowPeaks
However, when I try to install the package, the installation of flowPeaks fails, because the script downloades the source version of the package, which requires GSL to be present in order to be compiled.
* installing *source* package ‘flowPeaks’ ...
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include `gsl-config --cflags` -fPIC -Wall -g -O2 -c Rpack.cpp -o Rpack.o
/bin/sh: gsl-config: command not found
In file included from Rpack.cpp:16:
./gvector_gmatrix.h:24:10: fatal error: 'gsl/gsl_math.h' file not found
#include <gsl/gsl_math.h>
^
1 error generated.
make: *** [Rpack.o] Error 1
ERROR: compilation failed for package ‘flowPeaks’
When I download the package manually from Bioconductor, everything works fine, because the script downloades the binary version of the package. Can I specify somewhere that this is the default behaviour? I tried options(pkgType = "binary") without success.
Edit: No new ideas, so I'm bumping it once.

Related

Unable to install blotter or quantstrat for R 4.0.2, despite using GitHub Repository

Having a difficult time installing blotter for 4.0.2.
I run the following code:
require(devtools)
install_github("braverock/blotter")
install_github("braverock/quantstrat")
I receive the following error message:
Failed to install 'blotter' from GitHub:
(converted from warning) installation of package ‘/var/folders/7f/fzwn25053j3bp0yd_7swzf540000gn/T//Rtmp5kiwSh/file14db938bb63bf/blotter_0.15.0.tar.gz’ had non-zero exit status
I have successfully installed xts, PerformanceAnalytics, and FinancialInstrument. I also have installed the development tool Clang 8.0 (although I believe it is no longer necessary in R 4.0 and higher).
Any help is appreciated. Thanks in advance.
Edit - Full Output:
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c calcPosAvgCost.c -o calcPosAvgCost.o
calcPosAvgCost.c:31:12: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
if(abs(d_PrevPosQty) > abs(d_PosQty[i])){
^
calcPosAvgCost.c:31:12: note: use function 'fabs' instead
if(abs(d_PrevPosQty) > abs(d_PosQty[i])){
^~~
fabs
calcPosAvgCost.c:31:32: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
if(abs(d_PrevPosQty) > abs(d_PosQty[i])){
^
calcPosAvgCost.c:31:32: note: use function 'fabs' instead
if(abs(d_PrevPosQty) > abs(d_PosQty[i])){
^~~
fabs
2 warnings generated.
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c init.c -o init.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o blotter.so calcPosAvgCost.o init.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-blotter/00new/blotter/libs
** R
** data
*** moving datasets to lazyload DB
** demo
** byte-compile and prepare package for lazy loading
Error: (converted from warning) package ‘xts’ was built under R version 4.0.2
Execution halted
ERROR: lazy loading failed for package ‘blotter’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/blotter’
Error: Failed to install 'blotter' from GitHub:
(converted from warning) installation of package ‘/var/folders/7f/fzwn25053j3bp0yd_7swzf540000gn/T//Rtmp5kiwSh/file14db956d7f3bb/blotter_0.15.0.tar.gz’ had non-zero exit status
Ok I found the fix to this issue.
I followed the formula from a previous question regarding quanstrat from #boniface316:
Installing quantstrat via cmd works well for me. Here are the steps:
Create a folder for packages i.e RPackages\
Download the file from github to that specific folder and extract the files to the library name. i.e RPackages\quantstrat\
Go on command line and goto RPackages
Type" R CMD build quantstrat
If it was successful, you will get a message like "building 'package_name_version_number.tar.gz'"
Now type: R CMD INSTALL package_name_version_number.tar.gz
Let me know if you have any other challenges.
This allowed me to install Blotter but not Quantstrat. After playing around with this for awhile, I eventually deleted the Vignettes folder in quanstrat and repeated the steps above. By deleting this folder, I was able to both build and install quantstrat.
After manually installing blotter (check the steps given in the above post), running this command worked for me. This is for the latest R versions (3.6 or 4.0 ).
devtools::install_github("braverock/quantstrat", force = TRUE )
or download the older (for R 3.4 or older) version zip from "https://r-forge.r-project.org/R/?group_id=316"
(note: you might see "Build status: Failed to build", hence download the older version, you can see the option on the page )

R package source install, no compiler

I am trying to install some packages from source on a linux (RHEL) server. But whenever the package requires some C++ compilation it fails.
For example, I try to install Ckmeans.1d.dp package. If I call R CMD INSTALL Ckmeans.1.dp_4.2.1.tar.gz I get the following output (truncated) where you can see the compiler is omitted.
...* installing *source* package ‘Ckmeans.1d.dp’ ...
** libs
I/usr/include/R -DNDEBUG -I/usr/local/include -c Ckmeans.1d.dp.cpp -o Ckmeans.1d.dp.o
make: I/usr/include/R: Command not found
...
-shared -L/usr/local/lib64 -o Ckmeans.1d.dp.so Ckmeans.1d.dp.o Ckmeans.1d.dp_main.o dynamic_prog.o fill_SMAWK.o fill_log_linear.o fill_quadratic.o select_levels.o weighted_select_levels.o -L/usr/lib64/R/lib -lR
/bin/sh: line 2: -shared: command not found
make: *** [Ckmeans.1d.dp.so] Error 127
ERROR: compilation failed for package ‘Ckmeans.1d.dp’
I am currently stuck with a server that only has R 3.1.1 and I do not have admin privileges. The $Rhome/etc/Makeconf has CXX and CC defined. I have also verified g++ and gcc are installed.
What could be happening here?
Invariably an environment variable with an 'empty' value gets expanded. Maybe (just guessing here) the package would use C++11, so $(CXX11} -shared gets expanded and ... becomes -shared and an error is triggered.
Look at the R settings, eg via less $(R HOME)/etc/Makevars and see what it expects.
I think you can get by, if you must, installing gcc et al below, say, ~/bin. Some packages will require a compiler...

Can't install R package: "non-zero exit status" (unless sudo)

Strange behavior: prior to now, I've been able to install R packages using R studio, etc., specifically using install.packages("<package name>"). Now, unless I run R using sudo directly in a terminal window, I can't install packages without receiving the following traceback:
> install.packages("mlbench")
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://mirrors.sorengard.com/cran/src/contrib/mlbench_2.1-1.tar.gz'
Content type 'application/x-gzip' length 920768 bytes (899 KB)
==================================================
downloaded 899 KB
* installing *source* package ‘mlbench’ ...
** package ‘mlbench’ successfully unpacked and MD5 sums checked
** libs
/home/alex/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -I/home/alex/anaconda3/lib/R/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -I/home/alex/anaconda3/include -fpic -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -I/home/alex/anaconda3/include -c waveform.c -o waveform.o
make: /home/alex/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc: Command not found
/home/alex/anaconda3/lib/R/etc/Makeconf:160: recipe for target 'waveform.o' failed
make: *** [waveform.o] Error 127
ERROR: compilation failed for package ‘mlbench’
* removing ‘/home/alex/anaconda3/lib/R/library/mlbench’
* restoring previous ‘/home/alex/anaconda3/lib/R/library/mlbench’
The downloaded source packages are in
‘/tmp/RtmpRBWDWi/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("mlbench") :
installation of package ‘mlbench’ had non-zero exit status
This is happening for quite a few that I have tried, but mlbench is the one that I am most concerned with right now.
Any help is much appreciated.
R (with anaconda)
Kubuntu 17.10 (Artful)
As posted by #r2evans in the comments, this link provides the tip that worked for me.
Because I am using anaconda to manage my R environment, this is what fixed the issue I was having: conda install gxx_linux-64.
Also:
If you are seeing similar errors but with a traceback line similar to make: /home/alex/anaconda3/bin/x86_64-conda_cos6-linux-gnu-gfortran: Command not found..., use a terminal to run the same line as above, but specifying gfortran instead of gcc: conda install gfortran_linux-64.

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

Installing nloptr on Linux

I am trying to install the R package nloptr on a CentOS Linux machine that doesn't have internet connection as follows:
install.packages("/home/ravi/nloptr_1.0.4.tar.gz", repos = NULL, type="source")
This command in turn looks for the following file online
http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz
However, this fails since there is no internet connection to the machine.
I tried the suggestion from the following stackoverflow post:
trouble with Installing nloptr by locally on Ubuntu
I changed the URL in configure and configure.ac files as follows:
NLOPT_URL="file:///home//ravi//${NLOPT_TGZ}"
However, I get the following error when I try to install the package again:
> install.packages("/home/ravi/nloptr_1.0.4.tar.gz", repos = NULL, type="source")
* installing *source* package 'nloptr' ...
files 'configure', 'configure.ac' have the wrong MD5 checksums
ERROR: 'configure' exists but is not executable -- see the 'R Installation and Administration Manual'
* removing '/opt/vertica/R/library/nloptr'
Warning message:
In install.packages("/home/ravi/nloptr_1.0.4.tar.gz", :
installation of package '/home/ravi/nloptr_1.0.4.tar.gz' had non-zero exit status
Can someone guide me on how to install this R package locally?
Update 1
Based on the suggestion from Dirk on installing nlopt first, I followed the instructions given in the following page:
http://ab-initio.mit.edu/wiki/index.php/NLopt_Installation
I installed nlopt as follows :
./configure --enable-shared
make
make install
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
When I tried to re-install nloptr in R, it doesn't look for the nlopt link anymore but throws the following error:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/opt/vertica/R/library/nloptr/libs/nloptr.so':
/opt/vertica/R/library/nloptr/libs/nloptr.so: undefined symbol: nlopt_set_maxtime
Error: loading failed
Execution halted
ERROR: loading failed
* removing '/opt/vertica/R/library/nloptr'
Warning message:
In install.packages("/home/ravi/nloptr_1.0.4.tar.gz", :
installation of package '/home/ravi/nloptr_1.0.4.tar.gz' had non-zero exit status
Update 2
As suggested by Dirk, I looked into the ldconfig command and used the following reference:
http://codeyarns.com/2014/01/14/how-to-add-library-directory-to-ldconfig-cache/
I edited the /etc/ld.so.conf file, added the directory /usr/local/lib which contains the shared library and ran the ldconfig command. This added the relevant shared library as shown below:
libnlopt.so.0 (libc6,x86-64) => /usr/local/lib/libnlopt.so.0
libnlopt.so (libc6,x86-64) => /usr/local/lib/libnlopt.so
However, when I tried reinstalling the nloptr package, I still get the same shared object error.
Could someone guide me on the shared library error?
When you say [t]his command in turn looks for the following file online you only get half the story. Together with Jelmer, the maintainer of the actual nloptr package, I modified the package to do the following:
look for an install libnlopt library, and, if found, use it
if not found fall back to the old behaviour and download the library
So you could simply install nlopt via
sudo apt-get install libnlopt-dev
(or the equivalent sudo dpkg -i /media/.... pointing to the file from a
USB drive etc pp) and then reinstall the nloptr package. It will just work. On my machine:
edd#max:~$ install.r nloptr ## install.r is in littler
trying URL 'http://cran.rstudio.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/x-gzip' length 353942 bytes (345 KB)
==================================================
downloaded 345 KB
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for pkg-config... yes
configure: Now testing for NLopt header file.
[...]
checking for nlopt.h... yes
configure: Suitable NLopt library found.
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -O3 -Wall -pipe -Wno-unused -pedantic -c dummy.cpp -o dummy.o
gcc -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -O3 -Wall -pipe -pedantic -std=gnu99 -c nloptr.c -o nloptr.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o nloptr.so dummy.o nloptr.o -lnlopt -lm -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/nloptr/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (nloptr)
The downloaded source packages are in
‘/tmp/downloaded_packages’
edd#max:~$
Note how it compiled only two files from the actual R packages having found the nlopt installation.
I had exactly the same problem, on a production machine without direct Internet access, with Red Hat Enterprise Linux Server release 6.6 (Santiago). The fixups proposed above did not work: when installing the nlopt library on the system, the subsequent attempt to install nloptr fail with the "nlopt_set_maxtime" error. I tried to fiddle with compilation options for nlopt, to no avail. I even reproduced the problem on a Ubuntu machine with Internet connection: I uninstalled nloptr, installed nlopt on the system and then the nloptr installation failed.
At last I solved the issue taking the following steps:
Un-install nlopt from the operating system (make sure that it is thoroughly removed).
Manually download nlopt-2.4.2.tar.gz and copy it to /tmp/
Manually download nloptr_1.0.4.tar.gz to a work directory and unpack it; this creates the directory "nloptr/".
Edit "nloptr/configure", comment out the row
$("${R_HOME}/bin/Rscript" --vanilla -e
"download.file(url='${NLOPT_URL}', destfile='${NLOPT_TGZ}')")
and insert a new row:
$("${R_HOME}/bin/Rscript" --vanilla -e
"file.copy(from='/tmp/nlopt-2.4.2.tar.gz', to='${NLOPT_TGZ}')")
Install with "R CMD INSTALL nloptr".
I had a similar problem on Ubuntu. In addition to installing nlopt-dev as Dirk answered, I also had to install pkg-config:
sudo apt-get install pkg-config
Hope this helps.
If you are on CentOS (and have internet access, but the nlopt server is not reachable), you can install nlopt first using
yum install nlopt nlopt-devel
Then you can install nloptr normally.
I had the same issue setting up nloptr on my RHEL 7.2 instance. For those using RHEL you can do the following:
Download & install the following RPMS in the same order:
NLopt-2.4.2-2.el7.x86_64.rpm- https://pkgs.org/centos-7/epel-x86_64/NLopt-2.4.2-2.el7.x86_64.rpm.html
NLopt-devel-2.4.2-2.el7.x86_64.rpm - https://pkgs.org/centos-7/epel-x86_64/NLopt-devel-2.4.2-2.el7.x86_64.rpm.htm
Please note that these RPMs may need additional dependencies to be installed based on your system configuration.
Post this you can install nloptr directly using the install.packages utility or download source from CRAN and install from source as suggested in earlier responses.
Hope this helps!
Kiran
if you are using AWS Linux the below should help
yum --enablerepo=epel install NLopt-devel -y
I just solved this on my server with following two steps:
Install libnlopt-dev and nlopt with
sudo apt-get install libnlopt-dev
pip install nlopt
Use sudo R to launch R and type:
withr::with_makevars(c(PKG_LIBS='-lnlopt'),install.packages('nloptr'),assignment='+=')
I think I have the same problem as you and I am using CentOS 6.5
Remove nlopt and install nloptr with install.packages() in R, a nlopt will be installed automatically.
I removed installed nlopt with the following command in the unzipped nlopt folder.
make uninstall
If you had tried to use epel repository in CentOS and had installed nlopt with yum, try:
yum remove nlopt
After removing existed nlopt, I am able to install nloptr with
install.packages("nloptr")

Resources