R studio cannot find existing library - r

It seems that R studio cannot find a library (DirichletMultinomial.so)
I installed this library through R in command line. I had problem installing it with Rstudio, because this package requires gsl, which I compiled on my own (don't have sudo priviledge). I added the path of gsl libs to my $PATH and R command line was able to use it to install the packages. But Rstudio somehow still reports "gsl-config: command not found". It seems that Rstudio ignore my set up of $PATH completely and I have no idea how to fix it.
> library(TFBSTools)
Error: package or namespace load failed for ‘TFBSTools’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/bar/cfan/R/x86_64-pc-linux-gnu-library/3.5/DirichletMultinomial/libs/DirichletMultinomial.so':
libgsl.so.23: cannot open shared object file: No such file or directory
cfan#paleAle:~$ wc -l /bar/cfan/R/x86_64-pc-linux-gnu-library/3.5/DirichletMultinomial/libs/DirichletMultinomial.so
273 /bar/cfan/R/x86_64-pc-linux-gnu-library/3.5/DirichletMultinomial/libs/DirichletMultinomial.so

Related

Cannot load installed packages in R - "libR.so: cannot open shared object file: No such file or directory"

I'm using R on a linux server (Ubuntu 18.04.6 LTS). Occasionally I run into this issue where when trying to load a packages using library(PACKAGE) I get the following error:
Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/USER/R/sf/libs/sf.so':
libR.so: cannot open shared object file: No such file or directory
in this case when trying to load the sf package. However, when I check the directory, the file /home/USER/R/sf/libs/sf.so does exist. When this happens it is with code that previously ran and it usually happens with multiple packages (though not all of them).
Checking .libPaths() gives
[1] "/home/USER/R" "/opt/R/3.6.3/lib/R/library"
All my packages are installed in my directory (the first one above) as this is a shared server. Generally, reinstalling these packages (and sometimes dependencies) fixes this problem but that can be time consuming. Is there any other way to fix this problem? Thanks

ROracle not loading Instantclient library on MacOS High Sierra

I have installed Oracle Instant Client 12.1.0.2.0 and am now trying to install ROracle 1.3-1 for R with the following command:
R CMD INSTALL --configure-args='--with-oci-lib=/usr/local/oracle/instantclient12 --with-oci-inc=/usr/local/oracle/instantclient12/sdk/include' ROracle_1.3-1.tar.gz
The Oracle Instant Client is installed in /usr/local/oracle/instantclient12
Unfortunately, I am getting the following error at the end of the ROracle install and have been having a difficult time figuring out what is going wrong:
** testing if installed package can be loaded
Error: package or namespace load failed for ‘ROracle’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle/libs/ROracle.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle/libs/ROracle.so, 6): Library not loaded: #rpath/libclntsh.dylib.12.1
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle/libs/ROracle.so
Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle’
For whatever reason #rpath/libclntsh.dylib.12.1 can't be found and is preventing ROracle from being fully installed. I have tried putting a link to libclntsh.dylib.12.1 in ~/lib and /usr/lib but neither link worked. I have also tried pointing to the directory containing libclntsh.dylib.12.1 with the environment variables DYLD_FALLBACK_LIBRARY_PATH and DYLD_LIBRARY_PATH but those have not worked as well.
I am using MacOS High Sierra (10.13) and R 3.4.2.
The only way I have found so far to get around this problem is to put a link to libclntsh.dylib.12.1 in the framework lib directory for R. On my computer the R framework lib directory is located in /Library/Frameworks/R.framework/Resources/lib
My instant client is installed in /usr/local/oracle/instantclient12
So I use the following command to make the file link:
ln -s /usr/local/oracle/instantclient12/libclntsh.dylib.12.1 /Library/Frameworks/R.framework/Resources/lib/libclntsh.dylib.12.1
This resolves the ROracle install problem and I can now load the ROracle library in R without issue.

RGDAL installation error: libnetcdf.so.6: cannot open shared object file: No such file or directory

I run RStudio Server on ubuntu 14.04. When trying to install the rgdal package I get the following error message:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/admin2/R/x86_64-pc-linux-gnu- library/2.14/rgdal/libs/rgdal.so':
libnetcdf.so.6: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
I upgraded RStudio Server, R-Core and all Ubuntu packages to their latest versions but no success. I also tried apt-get install lib32stdc++6 as suggested here, but also no changes. I think it is a problem specific to GDAL and the indexing of shared libraries in unix. Can anyone help please?
Ok I got it done removing Gdal completly, compiling it from source again and setting library paths correctly as described here. Later adding /usr/local/lib/ to /etc/ld.so.conf and run sudo ldconfig as described here.

Error while installing "nloptr_1.0.4.tar.gz" from local

When i tried to install nloptr_1.0.4.tar.gz from local, It needed another unix library nlopt-2.4.2.tar.gz which I got it resolved from the following thread Error while installing a tar.gz package in R
But, even after that the package is not getting installed
It throws the following error,
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/cloudera/R/x86_64-redhat-linux-gnu-library/3.2/nloptr/libs/nloptr.so':
/home/cloudera/R/x86_64-redhat-linux-gnu-library/3.2/nloptr/libs/nloptr.so: undefined symbol: nlopt_set_maxtime
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/cloudera/R/x86_64-redhat-linux-gnu-library/3.2/nloptr’
For the above error, I got a lead from the following link:https://cran.r-project.org/web/packages/ROracle/INSTALL
and http://ab-initio.mit.edu/wiki/index.php/NLopt_Installation
Based on the above links, I had to set LD_LIBRARY_PATH variable to /usr/local/lib and /usr/local/include
Even after setting the above Environment variable, R CMD INSTALL nloptr_1.0.4.tar.gz is not getting installed and throwing the same error.
The fix is easy. On a Debian/Ubuntu system do
sudo apt-get install libnlopt-dev
as you always need the development package to compile a given library. It will then be found, and nloptr will install without a hitch.
Similarly on a RH/FC/CentOS with rpms.
Now, when I helped Jelmer rewrite the configuration for nloptr, we did make sure it worked both ways: with an install nlopt library, and without. You seem to stuck in the middle with one that is installed, but different ("missing symbol"). If you cannot uninstall that 'wrong' libnlopt, I would recommend altering the nloptr sources to not check for it but rather always build itself against a copy of nlopt 2.4.2 which it will download and compile statically.

RPostgreSQL installation Error - RPostgreSQL.so: undefined symbol: PQpass

I am trying to install R-Package RPostgreSQL, but getting the following error,
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/lib64/R/library/RPostgreSQL/libs/RPostgreSQL.so':
/usr/lib64/R/library/RPostgreSQL/libs/RPostgreSQL.so: undefined symbol: PQpass
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/lib64/R/library/RPostgreSQL’
I have libpq and postgresql-dev installed. All the library files are in the directory
/usr/lib64/pgsql/ and all header files are in the directory
/usr/include/pgsql/
Postgre Version - 9.3.4
R Version - 3.0.2
Operating System - CentOS-6.4
I am missing some small thing, but unable to find out why this is happening.
What am I doing wrong? How to correct this?
Looks like the pgsql libraries are no longer installed in their previous locations. I linked both:
ln -s /usr/pgsql-9.3/lib /usr/lib/pgsql
ln -s /usr/pgsql-9.3/include /usr/include/pgsql
This worked for me :)
The package RPostgreSQL checks for PostgreSQL libraries only in the following directory paths,
/usr/lib
/usr/lib/pgsql
/usr/lib/postgresql
/usr/local/lib
/usr/local/lib/pgsql
/usr/local/lib/postgresql
/usr/local/pgsql/lib
/usr/local/postgresql/lib
/opt/lib
/opt/lib/pgsql
/opt/lib/postgresql
/opt/local/lib
/opt/local/lib/postgresql
/opt/local/lib/postgresql84
/sw/opt/postgresql-8.4/lib
/Library/PostgresPlus/8.4SS/lib
/sw/lib
It does not check for the directories either in LD_LIBRARY_PATH or in /etc/ld.so.conf.
So RPostgreSQL installation will be successful only if the PostgreSQL libraries exist in any of the above directories.
When I copied the libraries from /usr/lib64/pgsql to /usr/lib/pgsql and tried installing the package. It worked. :)

Resources