R load error - libproj.so.13: cannot open shared object file: No such file or directory - r

I am trying to install CRANs population genetics package hierfstat; however the following error with libproj.so.13 is printed:
> install.packages("hierfstat")
Installing package into ‘/home/ecoevo/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/hierfstat_0.04-22.tar.gz'
Content type 'application/x-gzip' length 460778 bytes (449 KB)
==================================================
downloaded 449 KB
* installing *source* package ‘hierfstat’ ...
** package ‘hierfstat’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
** inst
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/ecoevo/R/x86_64-pc-linux-gnu-library/3.6/sf/libs/sf.so':
libproj.so.13: cannot open shared object file: No such file or directory
Calls: <Anonymous> ... namespaceImport -> loadNamespace -> library.dynam -> dyn.load
Execution halted
ERROR: lazy loading failed for package ‘hierfstat’
* removing ‘/home/ecoevo/R/x86_64-pc-linux-gnu-library/3.6/hierfstat’
* restoring previous ‘/home/ecoevo/R/x86_64-pc-linux-gnu-library/3.6/hierfstat’
Warning in install.packages :
installation of package ‘hierfstat’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpXDoNEK/downloaded_packages’
Any suggestions on how to fix this error? I am working on Ubuntu-20.04

I was also facing same issue with ubuntu 20.04. In my case, I had extend my LD library path.
In bash
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
In tcsh
setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:/lib
setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:/usr/lib
setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:/usr/local/lib
Afterwards, you could already see that shared libraries can now be found if
/usr/local/bin/proj
does not result in any error.

I had the same issue with package "stars" while working on a shared computer. Other packages I was able to install, but not this one.
The issue was solved by running R as sudo.
From Terminal:
sudo R # start R session as sudo
install.packages("<package_name>") # install your package
q() # quit R session

Related

Cannot install tmap tmaptools, Error unable to load shared object lwgeom.so': libproj.so.19

I cannot install the R packages tmaptools and tmap in ubuntu linux, I have followed the instructions in
https://geocompr.github.io/post/2020/installing-r-spatial-ubuntu/
I installed sf and checked:
library(sf)
Linking to GEOS 3.10.1, GDAL 3.4.0, PROJ 8.2.0; sf_use_s2() is TRUE
Warning messages:
1: replacing previous import ‘lifecycle::last_warnings’ by ‘rlang::last_warnings’ when loading ‘pillar’
2: replacing previous import ‘lifecycle::last_warnings’ by ‘rlang::last_warnings’ when loading ‘tibble’
When I try to instal tmaptools the following error appears
> install.packages("tmaptools")
Installing package into ‘/home/leonardo/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/tmaptools_3.1-1.tar.gz'
Content type 'application/x-gzip' length 40116 bytes (39 KB)
==================================================
downloaded 39 KB
* installing *source* package ‘tmaptools’ ...
** package ‘tmaptools’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** byte-compile and prepare package for lazy loading
Warning: replacing previous import ‘lifecycle::last_warnings’ by ‘rlang::last_warnings’ when loading ‘pillar’
Warning: replacing previous import ‘lifecycle::last_warnings’ by ‘rlang::last_warnings’ when loading ‘tibble’
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/leonardo/R/x86_64-pc-linux-gnu-library/4.1/lwgeom/libs/lwgeom.so':
libproj.so.19: cannot open shared object file: No such file or directory
Calls: <Anonymous> ... asNamespace -> loadNamespace -> library.dynam -> dyn.load
Execution halted
ERROR: lazy loading failed for package ‘tmaptools’
* removing ‘/home/leonardo/R/x86_64-pc-linux-gnu-library/4.1/tmaptools’
Warning in install.packages :
installation of package ‘tmaptools’ had non-zero exit status
I have already removed the package and installed it again, but I always get the same error.
Browsing the tmap issues on github I found the answer:
install lwgeom package, so
install.packages("lwgeom")
Solved the problem.

CentOS install R package RLumShiny failed

I tried to install the shiny related package RLumShiny on the server.
System Version: CentOS Linux release 8.1.1911 (Core)
I tried to use :
install.packages("RLumShiny")
Some errors were returned. But I can't find these errors now.
And then i tired to use :
wget https://cran.r-project.org/bin/macosx/contrib/4.1/RLumShiny_0.2.2.tgz
R CMD INSTALL RLumShiny_0.2.2.tgz
R
library("RLumShiny")
The server reported an error:
>library(RLumShiny)
Error: package or namespace load failed for ‘RLumShiny’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/shiny/R/x86_64-redhat-linux-gnu-library/4.1/terra/libs/terra.so':
/home/shiny/R/x86_64-redhat-linux-gnu-library/4.1/terra/libs/terra.so: invalid ELF header
Then i tried :
>install.packages("RLumShiny")
Installing package into ‘/home/shiny/R/x86_64-redhat-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
try open URL'https://mirror-hk.koddos.net/CRAN/src/contrib/RLumShiny_0.2.2.tar.gz'
Content type 'application/x-gzip' length 448539 bytes (438 KB)
==================================================
downloaded 438 KB
installing *source* package ‘RLumShiny’ ...
package ‘RLumShiny’ successfully unpacked and MD5 sums checked
using staged installation
R
inst
byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/shiny/R/x86_64-redhat-linux-gnu-library/4.1/terra/libs/terra.so':
/home/shiny/R/x86_64-redhat-linux-gnu-library/4.1/terra/libs/terra.so: invalid ELF header
Calls: <Anonymous> ... namespaceImport -> loadNamespace -> library.dynam -> dyn.load
Execution halted
ERROR: lazy loading failed for package ‘RLumShiny’
* removing ‘/home/shiny/R/x86_64-redhat-linux-gnu-library/4.1/RLumShiny’
* restoring previous ‘/home/shiny/R/x86_64-redhat-linux-gnu-library/4.1/RLumShiny’
The downloaded source packages are in
‘/tmp/RtmpZxd0sL/downloaded_packages’
Warning message:
In install.packages("RLumShiny") :
installation of package ‘RLumShiny’ had non-zero exit status
How can this be fixed?
The problem is clearly with the terra package. So the way to fix it would be to (re-) install that package first; perhaps after installing its system requirements (see the repo) perhaps with
sudo dnf install gdal-devel proj-devel geos-devel sqlite-devel

Unable to install package RGLPK with R Studio Server in AWS

I am trying to install the package RGLPK with an AWS EC2 instance which has R Studio 1.3 and R 4.0 running. I get this result:
> install.packages("Rglpk")
Installing package into ‘/home/rstudio/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/Rglpk_0.6-4.tar.gz'
Content type 'application/x-gzip' length 21753 bytes (21 KB)
==================================================
downloaded 21 KB
* installing *source* package ‘Rglpk’ ...
** package ‘Rglpk’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/bin/bash: line 0: cd: GLPK: No such file or directory
Makevars:10: recipe for target 'GLPK.ts' failed
make: *** [GLPK.ts] Error 1
ERROR: compilation failed for package ‘Rglpk’
* removing ‘/home/rstudio/R/x86_64-pc-linux-gnu-library/4.0/Rglpk’
Warning in install.packages :
installation of package ‘Rglpk’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpHmQk09/downloaded_packages’
I have found numerous similar errors involving this package. Such as this:
GLPK: No such file or directory error when trying to install R package
There seems to be 3 or 4 solutions, but they involve sudo commands from the terminal window. I am in a virtual machine.
This worked:
In the terminal within R Studio Server:
sudo apt install libglpk-dev
And back in the console, install the R library:
install.packages("Rglpk")
Credit: #AdamErickson from this post:
GLPK: No such file or directory error when trying to install R package

Unable to install sandwich package: installation of package ‘sandwich’ had non-zero exit status

I need to install the "plm" package. After installing it, the "sandwich" package was missing.
> library(plm)
Error: package or namespace load failed for ‘plm’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘sandwich
Tried to install the "sandwich" package, returned with this:
Installing package into ‘library_path’
(as ‘lib’ is unspecified)
also installing the dependency ‘zoo’
There is a binary version available but the source version is later:
binary source needs_compilation
sandwich 2.3-4 2.4-0 FALSE
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/zoo_1.8-0.zip'
Content type 'application/zip' length 901864 bytes (880 KB)
downloaded 880 KB
package ‘zoo’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\directory\downloaded_packages
installing the source package ‘sandwich’
trying URL 'https://cran.rstudio.com/src/contrib/sandwich_2.4-0.tar.gz'
Content type 'application/x-gzip' length 1280592 bytes (1.2 MB)
downloaded 1.2 MB
'\\directory\My Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
* installing *source* package 'sandwich' ...
** package 'sandwich' successfully unpacked and MD5 sums checked
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
Warning in file(con, "w") :
cannot open file '\\library_path/sandwich/doc/index.html': No such file or directory
Error in file(con, "w") : cannot open the connection
ERROR: installing vignettes failed
* removing '\\library_path/sandwich'
Warning in install.packages :
running command '"C:/R-34~1.1/bin/x64/R" CMD INSTALL -l "\\library_path" C:\directory/downloaded_packages/sandwich_2.4-0.tar.gz' had status 1
Warning in install.packages :
installation of package ‘sandwich’ had non-zero exit status
The downloaded source packages are in
‘C:\directory\downloaded_packages’
Had tried:
Reinstall R and RStudio directly to C (not in C:\Program Files)
Using this command to install all the dependencies:
install.packages("sandwich", dependencies=TRUE)
Still, the "non-zero exit status" appeared. Do you have any suggestions?
I am using Windows 7 (64 bit), R 3.4.1 and RStudio 1.0.153
I think i found a temporary answer for my problem. I previously had problems related to the privilege in writing the library folder in R. Tried to work around by turning off anti-virus live update, change the security of the R folder, etc. I thought it was worked, since I did not find anymore issues on "unable to move temporary installation....". But when I restart my computer, the problem came again.
Since I am working in a university provided laptop, I need to wait until the IT grants me access as an admin. While waiting for it, I created a new library in C:/ (in my case, I named it as "R library local"). Downloaded all the package to that library
install.packages("plm", dependencies = TRUE, lib = "C:/R library local")
And load the package from the library
library("plm", lib="C:/R library local")
It works well :)
Dunno if I still need the admin access for the library in R folder or not.

Hive library installation in R : error

I want to connect R with Hive using hive package, however I am unable to
install hive library in R.. Please help.
I am using R Server which is in the same machine where my hadoop (hartoworks 2.1 ) cluster cluster is there.
Below is the error message.
Sys.setenv("hive_home" ="/usr/lib/hive")
Sys.setenv("hadoop_home"="/usr/lib/hadoop")
install.packages("hive", dependencies=T)
Installing package into ‘/home/rk/R/x86_64-redhat-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/hive_0.2-0.tar.gz'
Content type 'application/x-gzip' length 32886 bytes (32 KB)
opened URL
==================================================
downloaded 32 KB
* installing *source* package ‘hive’ ...
** package ‘hive’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
converting help for package ‘hive’
finding HTML links ... done
DFS html
configuration html
hive html
hive_stream html
** building package indices
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'hive', details:
call: .jnew("org/apache/hadoop/fs/Path", file.path(hadoop_home(henv),
error: java.lang.ClassNotFoundException
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/rk/R/x86_64-redhat-linux-gnu-library/3.1/hive’
* restoring previous ‘/home/rk/R/x86_64-redhat-linux-gnu-library/3.1/hive’
Warning in install.packages :
installation of package ‘hive’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpDsXs7i/downloaded_packages’

Resources