Cannot reinstall or run Stringr package - r

I recently upgrade ubuntu from 18.04 to 20.04, so this is probably related...
My code requires me to have the stringr package and to use tidyverse. When I try to run require(stringr) and library(tidyverse) I receive these errors,
> require(stringr) # String manipulation
Loading required package: stringr
Error: package or namespace load failed for ‘stringr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/elrodlab/R/x86_64-pc-linux-gnu-library/3.6/stringi/libs/stringi.so':
libicui18n.so.60: cannot open shared object file: No such file or directory
> library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/elrodlab/R/x86_64-pc-linux-gnu-library/3.6/stringi/libs/stringi.so':
libicui18n.so.60: cannot open shared object file: No such file or directory
I've tried reinstalling stringr using install.packages("stringr") but then get
Installing package into ‘/home/elrodlab/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/stringr_1.4.0.tar.gz'
Content type 'application/x-gzip' length 135777 bytes (132 KB)
==================================================
downloaded 132 KB
* installing *source* package ‘stringr’ ...
** package ‘stringr’ successfully unpacked and MD5 sums checked
mv: cannot move '/home/elrodlab/R/x86_64-pc-linux-gnu-library/3.6/stringr' to '/home/elrodlab/R/x86_64-pc-linux-gnu-library/3.6/00LOCK-stringr/stringr': Permission denied
ERROR: cannot remove earlier installation, is it in use?
* removing ‘/home/elrodlab/R/x86_64-pc-linux-gnu-library/3.6/stringr’
Warning in install.packages :
installation of package ‘stringr’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmptRvgMm/downloaded_packages’
Although it seems as if Stringr is good to go and all there, when I attempt to use require(stringr) I end up getting this error
Loading required package: stringr Error: package or namespace load failed for ‘stringr’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/home/elrodlab/R/x86_64-pc-linux-gnu-library/3.6/stringi/libs/stringi.so': libicui18n.so.60: cannot open shared object file: No such file or directory
Any idea on how to handle this?

The second message seems to indicate that stringr was actually successfully installed. Try running again
require(stringr)

Related

Error: package or namespace load failed for ‘RCurl’ in dyn.load(file, DLLpath = DLLpath, ...):

Error: package or namespace load failed for ‘RCurl’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-RCurl/00new/RCurl/libs/RCurl.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-RCurl/00new/RCurl/libs/RCurl.so, 0x0006): Library not loaded: '#rpath/libcurl.4.dylib'
Referenced from: '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-RCurl/00new/RCurl/libs/RCurl.so'
Reason: tried: '/Library/Frameworks/R.framework/Resources/lib/libcurl.4.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-17.0.1+12/Contents/Home/lib/server/libcurl.4.dylib' (no such file)
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RCurl’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RCurl’
Warning in install.packages :
installation of package ‘RCurl’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/9m/2mfljv2d3bbc0gdnxk892dzm0000gn/T/RtmpiKY9tT/downloaded_packages’
I found some solutions on Linux. On macOS, I don't see any solution.
I ran into the same issue. For me the issue was the conflicting curl-config installed system-wide on mac and the curl-config in my base conda environment that was getting auto-activated.
Steps that worked for me.
Run conda deactivate to deactivate the conda environment
Start R
Run the package installation again (install.packages("RCurl")).

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

How do i install the "nloptr" package correctly on my MAC?

I tried to install the "nloptr" package in R. (I have a Mac) I have "nlopt" already installed but still get the following error when I try to install "nloptr".
Error: package or namespace load failed for ‘nloptr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-nloptr/00new/nloptr/libs/nloptr.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-nloptr/00new/nloptr/libs/nloptr.so, 6): Symbol not found: _nlopt_add_equality_constraint
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-nloptr/00new/nloptr/libs/nloptr.so
Expected in: flat namespace
in /Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-nloptr/00new/nloptr/libs/nloptr.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/nloptr’
Warning in install.packages :
installation of package ‘nloptr’ had non-zero exit status
Can someone please help me with this?

R: cannot install packages after downgrading from 3.5 to 3.4. Error in dyn.load(file, DLLpath = DLLpath, ...)

I had installed R 3.5.1 as detailed in here, but I had some problem with some packages (namely rJava and XML), so I have decided to uninstall R 3.5.1 and downgrade to R 3.4.4 from the Ubuntu 18.04 repositories.
I did that successfully, but now, when I try to reinstall any CRAN package inside R with, for example:
install.packages("ggplot2")
library(ggplot2)
I get the following errors:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/local/lib/R/site-library/Rcpp/libs/Rcpp.so':
/usr/local/lib/R/site-library/Rcpp/libs/Rcpp.so: undefined symbol: DATAPTR
ERROR: lazy loading failed for package ‘ggplot2’
* removing ‘/usr/local/lib/R/site-library/ggplot2’
* restoring previous ‘/usr/local/lib/R/site-library/ggplot2’
The downloaded source packages are in
‘/tmp/RtmpFKBMdd/downloaded_packages’
Warning message:
In install.packages("ggplot2") :
installation of package ‘ggplot2’ had non-zero exit status
>
>
>
>
> library(ggplot2)
Error: package or namespace load failed for ‘ggplot2’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/local/lib/R/site-library/Rcpp/libs/Rcpp.so':
/usr/local/lib/R/site-library/Rcpp/libs/Rcpp.so: undefined symbol: DATAPTR
In addition: Warning message:
package ‘ggplot2’ was built under R version 3.5.1
Any clue how to solve this? Thanks
OK this script to remove all user installed packages works like a charm if anyone is interested. It was taken from here.
# Shamlessly stolen from:
# https://www.r-bloggers.com/how-to-remove-all-user-installed-packages-in-r/
# create a list of all installed packages
ip <- as.data.frame(installed.packages())
head(ip)
# if you use MRO, make sure that no packages in this library will be removed
ip <- subset(ip, !grepl("MRO", ip$LibPath))
# we don't want to remove base or recommended packages either\
ip <- ip[!(ip[,"Priority"] %in% c("base", "recommended")),]
# determine the library where the packages are installed
path.lib <- unique(ip$LibPath)
# create a vector with all the names of the packages you want to remove
pkgs.to.remove <- ip[,1]
head(pkgs.to.remove)
# remove the packages
sapply(pkgs.to.remove, remove.packages, lib = path.lib)

Problems with installing XVector package

I have problem with installing R package XVector.
I've tried to install it using biocLite:
Error: package or namespace load failed for ‘XVector’ in
dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object
'/home/fedorovaad/R/XVector/libs/XVector.so':
/home/fedorovaad/R/XVector/libs/XVector.so: undefined symbol:egzrewind
Error: loading failed
Execution halted
ERROR: loading failed
Also I used R CMD INSTALL XVector_0.16.0.tar.gz (the same error).
Besides I remove old version of Xvector (the same error...)
How can I fix it?

Resources