Trouble installing packages in RStudio on Linux - r

I'm trying to install the following package in RStudio on Linux. I'm getting the follow error code. I don't really understand it. I was wondering if anyone could help me make sense of it.
Thanks,
Nick
> install.packages("PKI")
Installing package into ‘/home/nick/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/PKI_0.1-3.tar.gz'
Content type 'application/x-gzip' length 31058 bytes (30 KB)
==================================================
downloaded 30 KB
* installing *source* package ‘PKI’ ...
** package ‘PKI’ successfully unpacked and MD5 sums checked
** libs
gcc -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -c asn1.c -o asn1.o
gcc -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -c init.c -o init.o
gcc -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -c pki-x509.c -o pki-x509.o
pki-x509.c: In function ‘PKI_extract_key’:
pki-x509.c:136:26: error: dereferencing pointer to incomplete type ‘EVP_PKEY {aka struct evp_pkey_st}’
if (EVP_PKEY_type(key->type) != EVP_PKEY_RSA)
^~
pki-x509.c: In function ‘get_cipher’:
pki-x509.c:244:40: error: dereferencing pointer to incomplete type ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
ctx = (EVP_CIPHER_CTX*) malloc(sizeof(*ctx));
^~~~
pki-x509.c: In function ‘PKI_RSAkeygen’:
pki-x509.c:550:5: warning: ‘RSA_generate_key’ is deprecated [-Wdeprecated-declarations]
rsa = RSA_generate_key(bits, 65537, 0, 0);
^~~
In file included from /usr/include/openssl/rsa.h:13:0,
from pki.h:13,
from pki-x509.c:1:
/usr/include/openssl/rsa.h:193:1: note: declared here
DEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void
^
make: *** [/usr/lib64/R/etc/Makeconf:159: pki-x509.o] Error 1
ERROR: compilation failed for package ‘PKI’
* removing ‘/home/nick/R/x86_64-pc-linux-gnu-library/3.4/PKI’
Warning in install.packages :
installation of package ‘PKI’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpttDG6C/downloaded_packages’

I think I had the same problem recently.
I installed the package by downloading the most recent tarball (the .tar.gz file PKI_0.1-5.tar.gz) from the PKI RForge page and then running
install.packages(<tarball_path>, repos = NULL, type = "source").
EDIT: Actually, it's easier to run install.packages('PKI',,'http://www.rforge.net/') as written in small print at the bottom of the PKI RForge page
EDIT2: Looking at the news, it looks like version 0.1-4 (perhaps more stable) also fixes the problem and, well enough, it works on my system, while 0.1-3 doesn't (the one on CRAN currently).

Related

Shared .so file not found when loading R package with Rcpp component Linux systems

I apologize in advance if this question has been asked before but I haven't been able to find a suitable answer after days of searching.
I have a package that has a couple of small functions written in C++ using Rcpp (package can be found here). When trying to install this package on Linux systems (both local install and via Github Actions - Ubuntu 18.04, 20.04) the compiling procedure was successful but R cannot load the package because an .so file was not found. Mac and Windows systems work fine and there were no R CMD CHECK issues when tested on these systems.
I was wondering if there is any way to solve this issue? I was thinking of adding something in .Makevars but I don't know what to add.
Thank you so much in advance.
─ installing *source* package ‘CBEA’ ...
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/local/lib/R/include" -DNDEBUG -I'/__w/_temp/Library/Rcpp/include' -I/usr/local/include -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -Wall -pedantic -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/local/lib/R/include" -DNDEBUG -I'/__w/_temp/Library/Rcpp/include' -I/usr/local/include -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -Wall -pedantic -c gmeans.cpp -o gmeans.o
g++ -std=gnu++11 -shared -L/usr/local/lib/R/lib -L/usr/local/lib -o CBEA.so RcppExports.o gmeans.o -L/usr/local/lib/R/lib -lR
installing to /tmp/RtmpwFufM0/Rinst8982598ffd0c/00LOCK-CBEA/00new/CBEA/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘CBEA’ in library.dynam(lib, package, package.lib):
shared object ‘cbea.so’ not found
Error: loading failed
Execution halted
ERROR: loading failed
─ removing ‘/tmp/RtmpwFufM0/Rinst8982598ffd0c/CBEA’
Your (generated) NAMESPACE file has two entries referring to the package:
useDynLib(CBEA, .registration = TRUE)
useDynLib(cbea, .registration = TRUE)
Remove the second one (i.e. remove whereever you tell roxygen2 to add it, and you will be fine. The rror message you see and quote indicates a case issue as on Linux, cbea.so is different from CBEA.so (whereas macOS and Windows let you get away with it).

`isoband` package installation fails, `testthat.h` not found

I have R (version 3.6.3 (2020-02-29), Holding the Windsock) installed on Ubuntu 18.04.4 LTS. When I try to install ggplot2 from source, the installation of dependency package isoband fails with testthat.h not found. The full output:
> install.packages("ggplot2")
Installing package into ‘/home/oszkar/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependency ‘isoband’
trying URL 'https://cloud.r-project.org/src/contrib/isoband_0.2.1.tar.gz'
Content type 'application/x-gzip' length 2293333 bytes (2.2 MB)
==================================================
downloaded 2.2 MB
trying URL 'https://cloud.r-project.org/src/contrib/ggplot2_3.3.0.tar.gz'
Content type 'application/x-gzip' length 3031461 bytes (2.9 MB)
==================================================
downloaded 2.9 MB
* installing *source* package ‘isoband’ ...
** package ‘isoband’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG
-I"/home/oszkar/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include"
-I"/usr/local/lib/R/site-library/testthat/include" -fpic -g -O2
-fdebug-prefix-map=/build/r-base-V28x5H/r-base-3.6.3=.
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG
-I"/home/oszkar/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include"
-I"/usr/local/lib/R/site-library/testthat/include" -fpic -g -O2
-fdebug-prefix-map=/build/r-base-V28x5H/r-base-3.6.3=.
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g -c clip-lines.cpp -o clip-lines.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG
-I"/home/oszkar/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include"
-I"/usr/local/lib/R/site-library/testthat/include" -fpic -g -O2
-fdebug-prefix-map=/build/r-base-V28x5H/r-base-3.6.3=.
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g -c isoband.cpp -o isoband.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG
-I"/home/oszkar/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include"
-I"/usr/local/lib/R/site-library/testthat/include" -fpic -g -O2
-fdebug-prefix-map=/build/r-base-V28x5H/r-base-3.6.3=.
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g -c polygon.cpp -o polygon.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG
-I"/home/oszkar/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include"
-I"/usr/local/lib/R/site-library/testthat/include" -fpic -g -O2
-fdebug-prefix-map=/build/r-base-V28x5H/r-base-3.6.3=.
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g -c separate-polygons.cpp -o separate-polygons.o
separate-polygons.cpp:4:10: fatal error: testthat.h: No such file or directory
#include <testthat.h>
^~~~~~~~~~~~
compilation terminated.
/usr/lib/R/etc/Makeconf:177: recipe for target 'separate-polygons.o' failed
make: *** [separate-polygons.o] Error 1
ERROR: compilation failed for package ‘isoband’
* removing ‘/home/oszkar/R/x86_64-pc-linux-gnu-library/3.6/isoband’
Warning in install.packages :
installation of package ‘isoband’ had non-zero exit status
ERROR: dependency ‘isoband’ is not available for package ‘ggplot2’
* removing ‘/home/oszkar/R/x86_64-pc-linux-gnu-library/3.6/ggplot2’
Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp5aYRcO/downloaded_packages’
I have already tried to install testthat manually, but it seems not to be available for R 3.6.3:
> install.packages("testthat")
...
Error: package or namespace load failed for ‘pkgload’:
.onLoad failed in loadNamespace() for 'pkgload', details:
call: NULL
error: package ‘testthat’ was installed by an R version with different internals;
it needs to be reinstalled for use with this R version
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/oszkar/R/x86_64-pc-linux-gnu-library/3.6/pkgload’
Warning in install.packages :
installation of package ‘pkgload’ had non-zero exit status
ERROR: dependency ‘pkgload’ is not available for package ‘testthat’
* removing ‘/home/oszkar/R/x86_64-pc-linux-gnu-library/3.6/testthat’
Warning in install.packages :
installation of package ‘testthat’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp5aYRcO/downloaded_packages’
Any idea would be appreciated.
Solved. The cause of the problem was that after a series of Ubuntu and R upgrades there were some outdated packages installed from source remained on my system.
First I opened up an R console and looking for the paths for R packages built with pre 3.6 version:
> unique(subset(as.data.frame(installed.packages()),
grepl("^3\\.[^6]", Built))[, "LibPath"])
[1] /usr/local/lib/R/site-library /usr/lib/R/library
As it is not possible to apply remove.packages() on these outdated packages, I switched to bash, and listed all the package paths:
>grep 'Built: R 3.[0-5]' /usr/local/lib/R/site-library/*/DESCRIPTION /usr/lib/R/library/*/
DESCRIPTION
I have removed (simply deleted from /usr/local/lib/R/site-library/ and /usr/lib/R/library/) the packages on the previous commands output, and now everything works.

How to solve dependence issues and error installing qpcR package?

I cannot install qpcR package, using this command in R:
install.packages("qpcR")
Apparently, everything looks fine initially:
Installing package into ‘/home/emanuel/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/qpcR_1.4-1.tar.gz'
Content type 'application/x-gzip' length 4303726 bytes (4.1 MB)
==================================================
downloaded 4.1 MB
* installing *source* package ‘qpcR’ ...
** package ‘qpcR’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack- protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c registerDynamicSymbol.c -o registerDynamicSymbol.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c smth.c -o smth.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o qpcR.so registerDynamicSymbol.o smth.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
And then things starts to going wrong:
usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'qpcR.so' failed
make: *** [qpcR.so] Error 1
ERROR: compilation failed for package ‘qpcR’
* removing ‘/home/emanuel/R/x86_64-pc-linux-gnu-library/3.4/qpcR’
Warning in install.packages :
installation of package ‘qpcR’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpOPiQkB/downloaded_packages’
Additional (maybe) relevant info:
Before the lines presented above, I was having trouble with another qpcR dependence, the rgl package, and I solved trying all the suggestions from another question: "Error in installing rgl package".
I made a brief search about: "-llpack", "-lblas", "qpcR.so" .Unfortunately nothing seems (to me at least) to be related to my specific problem.
I using Mint with these specifications: Linux version 4.8.0-53-generic (buildd#lgw01-56) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #56~16.04.1-Ubuntu
R version 3.4.4
R studio Version 1.1.453
Thanks in advance for any help!
satisfy the dependencies using this command in terminal.
sudo apt-get install libblas-dev liblapack-dev
hope this helps (Y)

RStudio AWS EC2 error when installing packages dependent on gsl

I set up an AWS EC2 instance of RStudio using the AMI provided by Louis Aslett.
However, when i try to install the package "topicsmodels" or "gsl" i get the following errors:
> install.packages("gsl")
Installing package into ‘/home/rstudio/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/gsl_1.9-10.3.tar.gz'
Content type 'application/x-gzip' length 172529 bytes (168 KB)
==================================================
downloaded 168 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 ‘/home/rstudio/R/x86_64-pc-linux-gnu-library/3.4/gsl’
Warning in install.packages :
installation of package ‘gsl’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpBItbU2/downloaded_packages’
and
> install.packages("topicmodels")
Installing package into ‘/home/rstudio/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/topicmodels_0.2-6.tar.gz'
Content type 'application/x-gzip' length 712766 bytes (696 KB)
==================================================
downloaded 696 KB
* installing *source* package ‘topicmodels’ ...
** package ‘topicmodels’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c cokus.c -o cokus.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c common.c -o common.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c ctm.c -o ctm.o
ctm.c:29:25: fatal error: gsl/gsl_rng.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:159: recipe for target 'ctm.o' failed
make: *** [ctm.o] Error 1
ERROR: compilation failed for package ‘topicmodels’
* removing ‘/home/rstudio/R/x86_64-pc-linux-gnu-library/3.4/topicmodels’
Warning in install.packages :
installation of package ‘topicmodels’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpBItbU2/downloaded_packages’
My knowledge of linux and RStudio server edition is fairly limited. I've tried following some intsructions from others who've experienced a similar problem, but none have worked (or i am unable to follow the instructions).
After googling a while this did work for me:
In Ubuntu to get topicmodels to install I needed to make sure that both:
GNU Scientific Library(GSL) -- binary package
GNU Scientific Library(GSL) -- development pacakage
were installed.

Trouble installing shiny dependencies on ubtuntu 12.04 to host apps on shiny-server.

When I go to my app address for a simple histogram app I get the following error:
An error has occurred
The application failed to start.
The application exited during initialization.
Error in eval(expr, envir, enclos) : The Shiny package was not found
in the library. Ensure that Shiny is installed and is available in the
Library of the user you're running this application as. Calls: local
-> eval.parent -> eval -> eval -> eval -> eval Execution halted
So I try to reinstall the shiny package and I get this message which I am having trouble interpreting into the next course of action. Maybe I need to be explicit about install dependencies?
xxxxxxxxxxxx:~$ sudo su - \
> -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
R version 3.1.0 RC (2014-04-05 r65382) -- "Spring Dance"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> install.packages('shiny', repos='http://cran.rstudio.com/')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
also installing the dependencies ‘Rcpp’, ‘httpuv’
trying URL 'http://cran.rstudio.com/src/contrib/Rcpp_0.11.1.tar.gz'
Content type 'application/x-gzip' length 2003515 bytes (1.9 Mb)
opened URL
==================================================
downloaded 1.9 Mb
trying URL 'http://cran.rstudio.com/src/contrib/httpuv_1.3.0.tar.gz'
Content type 'application/x-gzip' length 423739 bytes (413 Kb)
opened URL
==================================================
downloaded 413 Kb
trying URL 'http://cran.rstudio.com/src/contrib/shiny_0.9.1.tar.gz'
Content type 'application/x-gzip' length 958658 bytes (936 Kb)
opened URL
==================================================
downloaded 936 Kb
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG -I../inst/include/ -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -g -c Date.cpp -o Date.o
g++ -I/usr/share/R/include -DNDEBUG -I../inst/include/ -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -g -c Module.cpp -o Module.o
g++ -I/usr/share/R/include -DNDEBUG -I../inst/include/ -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -g -c Rcpp_init.cpp -o Rcpp_init.o
g++ -I/usr/share/R/include -DNDEBUG -I../inst/include/ -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -g -c api.cpp -o api.o
g++ -I/usr/share/R/include -DNDEBUG -I../inst/include/ -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -g -c attributes.cpp -o attributes.o
g++ -I/usr/share/R/include -DNDEBUG -I../inst/include/ -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -g -c barrier.cpp -o barrier.o
g++ -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/Rcpp/libs
** R
** inst
** preparing package for lazy loading
Error : package ‘codetools’ was built before R 3.0.0: please re-install it
Error : unable to load R code in package ‘Rcpp’
ERROR: lazy loading failed for package ‘Rcpp’
* removing ‘/usr/local/lib/R/site-library/Rcpp’
ERROR: dependency ‘Rcpp’ is not available for package ‘httpuv’
* removing ‘/usr/local/lib/R/site-library/httpuv’
ERROR: dependency ‘httpuv’ is not available for package ‘shiny’
* removing ‘/usr/local/lib/R/site-library/shiny’
The downloaded source packages are in
‘/tmp/RtmpRLRUsk/downloaded_packages’
Warning messages:
1: In install.packages("shiny", repos = "http://cran.rstudio.com/") :
installation of package ‘Rcpp’ had non-zero exit status
2: In install.packages("shiny", repos = "http://cran.rstudio.com/") :
installation of package ‘httpuv’ had non-zero exit status
3: In install.packages("shiny", repos = "http://cran.rstudio.com/") :
installation of package ‘shiny’ had non-zero exit status
After installing the codetools package according to jdharrison's advice, I retried installing shiny and then stated that I needed to reinstall RJSONIO. I then installed RJSONIO and tried installing shiny again. Now it is asking me for package caTools. When I install caTools it asks for bittops. I then try installing caTools again and it needs package digest. I install that, try shiny again and it asks for xtable. I install xtable and now shiny installs! now shiny server is working.

Resources