R: package installation trouble in Ubuntu - r

I'm running on Ubuntu 16.04 (on a Lenovo ThinkPak T450). I have installed R version 3.4.1, installed by following the instructions here via Rbloggers.
From here, I would like to start installing packages, but if I run R from the command line without root privileges, I cannot access a CRAN mirror. That is, when I run install.packages('dplyr') (or any install.packages('blah')) I get the following error
--- Please select a CRAN mirror for use in this session ---
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: Can't find a usable init.tcl in the following directories:
/opt/anaconda1anaconda2anaconda3/lib/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.18/library ./tcl8.5.18/library
With that error, no CRAN mirror dialog box appears and hence no installation of packages. Note: this error does not happen when I start R with root privileges (i.e., start via > sudo R), but I do not want to install packages as root.
Thanks in advance for any help you can send my way!
Edit: Specifying the repo also results in error (in the file paths below, I replaced my user-name with user-name).
E.g.: install.packages('Rcpp',repos='http://cran.us.r-project.org') terminates with:
installing to /home/user-name/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘Rcpp’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/user-name/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs/Rcpp.so':
/home/user-name/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs/Rcpp.so: undefined symbol: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/user-name/R/x86_64-pc-linux-gnu-library/3.4/Rcpp’
E.g., install.packages('dplyr',repos='http://cran.us.r-project.org') terminates with:
installing to /home/user-name/R/x86_64-pc-linux-gnu-library/3.4/dplyr/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/user-name/R/x86_64-pc-linux-gnu-library/3.4/bindrcpp/libs/bindrcpp.so':
/home/user-name/anaconda3/lib/R/bin/exec/../../lib/../.././libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/user-name/R/x86_64-pc-linux-gnu-library/3.4/bindrcpp/libs/bindrcpp.so)
ERROR: lazy loading failed for package ‘dplyr’
* removing ‘/home/user-name/R/x86_64-pc-linux-gnu-library/3.4/dplyr’

As pointed out by DirkEddelbuettel in the comments, the issue was a mixing of Anaconda and R. To fix this problem:
I uninstalled the R packages from Anaconda by first looking at > conda list and realizing that the package was r-base; hence running > conda remove r-base.
Next, by looking at the output of > which R, it was clear that we were still trying to execute from the ../anaconda3/bin/.. directory. I suspect there is a quick way to change this via an export or bashrc amendment (or something similar), but for me, the quickest work-around was to run > sudo apt-get install r-base r-base-dev, which took all of 0.2 seconds as they were already installed, but it did affect the directory which the system looks in to the appropriate one, for me this is /usr/bin/R/.
From here I've been able to install everything I've needed.
Note: Thinking back, I suspect the "mixing" happened when I installed rpy2 via conda.

Related

R tcl issue on shared HPC cluster environment

I've been having some issues getting R to run properly on the shared cluster at my institution , where i don't have root access. Some things will work but it gets tricky when i need to install packages etc. The current issue i'm trying to trouble shoot is the following error when trying to load the caret package:
Loading required package: lattice
Loading required package: ggplot2
Error: package or namespace load failed for ‘ggplot2’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/cifs/hariri-long/Scripts/Tools/R/packages/rlang/libs/rlang.so':
/cifs/hariri-long/Scripts/Tools/R/packages/rlang/libs/rlang.so: undefined symbol: R_removeVarFromFrame
Error: package ‘ggplot2’ could not be loaded
Execution halted
I found this page suggesting i install rlang as follows:
> install.packages("rlang",type="source")
Installing package into ‘/cifs/hariri-long/Scripts/Tools/R/packages’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: Can't find a usable init.tcl in the following directories:
/usr/share/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.13/library ./tcl8.5.13/library
but i get the above tcl error. since i've seen this in other threads:
> capabilities("tcltk")
tcltk
TRUE
it looks like tcl on my system is 8.6, but i don't know how to tell R to look for that version.
$ whereis tcl
tcl: /usr/lib64/tcl8.6 /usr/include/tcl.h /usr/share/tcl8.6
$ which R
/opt/apps/rhel7/R-3.6.0/bin/R
Any ideas? The OS is CentOS 8. Thanks!
I ended up deciding to try using a more recent R version (4.1.1) to solve this issue. I was hesitant to do this at first because I have run into issues with availability / compatibility of packages I need in more recent R versions, but I wasn't getting anywhere troubleshooting this issue otherwise. I figured that since TCL 8.6 is what was installed on the system, a newer version of R might be able to work with it, and seems i was right, since I got past the first error I was having when I switched.
I did get a new error regarding an issue loading the shared library Libtk8.6.so. So I downloaded the .so file from here and unpacked it to my home directory using rpm2cpio (i don't have root access so i can't just use yum install etc). After that i just had to re-install all my packages for the new R version and it worked!

Cannot install vroom under R.4.0.5 on HPC node

To install another package that depends on vroom (which failed) on a HPC node, I sought to install vroom manually.
I tried to install the package manually but it fails too:
My code:
install.packages("vroom")
error message:
installing to /home/leuph1/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-vroom/00new/vroom/libs
** R
** 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 ‘vroom’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/leuph1/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-vroom/00new/vroom/libs/vroom.so':
/home/leuph1/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-vroom/00new/vroom/libs/vroom.so: undefined symbol: __cxa_init_primary_exception
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/leuph1/R/x86_64-pc-linux-gnu-library/4.0/vroom’
Warning in install.packages :
installation of package ‘vroom’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpgPcp9Y/downloaded_packages’
I have tried under different R versions (3.5.3 up to 4.1.1) but keep having the same issue no matter what version I chose.
I have also deleted any 00LOCK-"package-name" folder that might have arisen in the process in the corresponding R Version package folder, but to no avail.
Can anybody help me out here?
Many thanks in advance,
Philibertus88

Trouble Installing qdap package into R

I want to install "qdap" package to run a text mining project. I tried installing the package in many different ways:
1. intsall.packages("qdap")
2. Downloading the file locally then installing
3. Using devtools
library(devtools)
install_github("trinker/qdapDictionaries")
install_github("trinker/qdapRegex")
install_github("trinker/qdapTools")
install_github("trinker/qdap")
I always had the same problem. It seems to be related to rJava package. I tried to install rJava but I wasn't successful.
I'm more of a data analyst than a developer so I don't have much experience with development (using terminal commands or fixing java on my mac).
I'd really like to use this "qdap" package. Could you please help me figure out in a simple manner?
Here's the error message after I install the package:
The downloaded source packages are in
‘/private/var/folders/hk/r0tjy0t57n79lvkh2_fc7snm0000gn/T/RtmpsSJ6Mg/downloaded_packages’
✓ checking for file ‘/private/var/folders/hk/r0tjy0t57n79lvkh2_fc7snm0000gn/T/RtmpsSJ6Mg/remotes42b1730aa4f/trinker-qdap-7f390f7/DESCRIPTION’ (437ms)
─ preparing ‘qdap’: (1.1s)
✓ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts (1.3s)
─ checking for empty or unneeded directories
Removed empty directory ‘qdap/tools’
─ looking to see if a ‘data/datalist’ file should be added
─ building ‘qdap_2.4.2.tar.gz’
* installing *source* package ‘qdap’ ...
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Warning in system("/usr/libexec/java_home", intern = TRUE) :
running command '/usr/libexec/java_home' had status 1
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
Reason: image not found
ERROR: lazy loading failed for package ‘qdap’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/qdap’
Error: Failed to install 'qdap' from GitHub:
(converted from warning) installation of package ‘/var/folders/hk/r0tjy0t57n79lvkh2_fc7snm0000gn/T//RtmpsSJ6Mg/file42b3e031f25/qdap_2.4.2.tar.gz’ had non-zero exit status
Maybe the key is in the following
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
and
Warning in system("/usr/libexec/java_home", intern = TRUE) :
running command '/usr/libexec/java_home' had status 1
Are you sure you have installed a JVM? And if yes, the correct one? Because it seems to not find it.
You can download JVM from here.
I hope this helps!

Can't install package 'Liszt' (not in CRAN) in R 3.6.3

I want to install a package that is not found in CRAN.
Below is a downloadlink to the package.
The package makes use of JAGS, of which i have the 64 bit 4.3.0 version of.
rjags and r2jags packages are installed. Rtools is connected to the pathway. I checked this using
Sys.which("make")
## "C:\\rtools40\\usr\\bin\\make.exe"
Connection to path was done with devtools from this Stacklink:
How to add Rtools\bin to the system path in R
I use the following code to install the downloaded .tar.gz package:
install.packages("C:/Program Files/R/R-3.6.3/Liszt_0.8-5_1.tar.gz", repos=NULL,
type="source")
The package won't installl, instead i get the following error:
* installing *source* package 'Liszt' ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'Liszt'
finding HTML links ... done
A3ModelFun html
A5ModelFun html
Caterpillar html
LL html
Liszt-package html
extract html
** building package indices
** testing if installed package can be loaded from temporary location
*** arch - i386
Error: package or namespace load failed for 'rjags':
.onLoad failed in loadNamespace() for 'rjags', details:
call: fun(libname, pkgname)
error: Failed to locate any version of JAGS version 4
The rjags package is just an interface to the JAGS library
Make sure you have installed JAGS-4.x.y.exe (for any x >=0, y>=0) from
http://www.sourceforge.net/projects/mcmc-jags/files
Error : package 'rjags' could not be loaded
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/Sneve/Documents/R/win-library/3.6/Liszt'
Warning in install.packages :
installation of package ‘C:/PROGRA~1/R/R-36~1.3/Liszt_0.8-5_1.tar.gz’ had non-zero exit status
I am trying for a while no, but no success. Any help is much appreciated.
Website providing the package:
http://www.possinghamlab.org/2016-05-30-04-33-10/list-length-analysis.html
package is available here:
http://www.possinghamlab.org/images/LLA/Liszt_0.8-5_1.tar.gz
I installed the 64 Bit version of JAGS. Appearently, the package needs both the 32 and the 64 bit version installed on the PC to be able to work. After i installed also the 32 bit version of JAGS, package installed with no problem.

coreNLP & rJava installation issue from gitbub in R

fellow stackoverflowers!
I was trying to install coreNLP from github as there is a bug in the coreNLP package that comes with R.
Now while installing the coreNLP from github using below
To download the R library and corresponding CoreNLP java library, run the following in R:
devtools::install_github("statsmaths/coreNLP")
coreNLP::downloadCoreNLP()
I got an error
installing source package 'coreNLP' ...
** R
** data
* moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
* installing help indices
** building package indices
** testing if installed package can be loaded
* arch - i386
Error: package or namespace load failed for 'coreNLP':
.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error: loading failed
Execution halted
* arch - x64
ERROR: loading failed for 'i386'
removing 'C:/Users/animshru/Documents/R/win-library/3.4/coreNLP'
Installation failed: Command failed (1)
After looking at many suggestions what I understood was
i) I was missing the class file path for Java Home and added the same and tried installing coreNLP again.
Sys.setenv(JAVA_HOME='C:/Program Files/Java/jre1.8.0_121')
devtools::install_github("statsmaths/coreNLP")
This time the error generated relates to the package/library rJava as seen below
Downloading GitHub repo statsmaths/coreNLP#master
from URL https://api.github.com/repos/statsmaths/coreNLP/zipball/master
Installing coreNLP
"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \
"C:/Users/XYZ/AppData/Local/Temp/RtmpieUxG6/devtools3c0456877ca/statsmaths-coreNLP-caee22e" \
--library="C:/Users/XYZ/Documents/R/win-library/3.4" --install-tests
installing source package 'coreNLP' ...
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/XYZ/Documents/R/win-library/3.4/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
ERROR: lazy loading failed for package 'coreNLP'
* removing 'C:/Users/XYZ/Documents/R/win-library/3.4/coreNLP'
Installation failed: Command failed (1)
I have installed the rJava package successfully and able to access the library for the same. Now I need to understand why I am getting this error of access issue to a rjava.dll file inside the package rJava.?
Has anyone encountered the same problem already??
I have double and triple checked the java version is 64bit same as the R.
Any hints folks??
Thanks

Resources