R: Error in dyn.load(file, DLLpath = DLLpath, ...)

29,618

Solution 1

I had a similar issue with rgdal on Ubuntu. Re-installing the package was enough to getting it working again.

$ sudo R
> install.packages("rgdal")
> quit()
$ exit

Solution 2

What is .libPaths() giving you as the output?

I encountered the same problem using the latest update today (R 3.3.1 for MacOS X). My R installation seemed to crash after updating it. My solution was simply to remove the lib directories from the file system and reinstall R:

rm -rf /Users/johann/Library/R/3.3/library
sudo rm -rf Library/Frameworks/R.framework/Versions/3.3/Resources/library

Hope this helps...

Share:
29,618
j91
Author by

j91

Updated on July 09, 2022

Comments

  • j91
    j91 almost 2 years

    I have worked now for some time on an R project in my office's desktop computer, but need to carry the scripts with me while on travel. I copied everything into my laptop and did some changes to the code. Alas, when trying to compile (following the exact same procedure I was using in my desktop computer), the following error:

    $ R CMD INSTALL --no-multiarch --with-keep.source coala
    * installing to library ‘/home/my_pc/R/x86_64-pc-linux-gnu-library/3.3’
    * installing *source* package ‘coala’ ...
    ** libs
    make: Nothing to be done for `all'.
    installing to /home/my_pc/R/x86_64-pc-linux-gnu-library/3.3/coala/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 in dyn.load(file, DLLpath = DLLpath, ...) : 
    unable to load shared object '/home/my_pc/R/x86_64-pc-linux-gnu-library/3.3/coala/libs/coala.so':
    /home/my_pc/R/x86_64-pc-linux-gnu-library/3.3/coala/libs/coala.so: undefined symbol: _ZSt24__throw_out_of_range_fmtPKcz
    Error: loading failed
    Execution halted
    ERROR: loading failed
    * removing ‘/home/my_pc/R/x86_64-pc-linux-gnu-library/3.3/coala’
    * restoring previous ‘/home/my_pc/R/x86_64-pc-linux-gnu-library/3.3/coala’
    

    Both computers have the same Ubuntu but different R version. Also, I have to mention that I am working in two libraries at the same time and that the accompanying library update without problems, which makes this error message more puzzling. I have checked answers that may be related to this question, but can't figure out how to apply their solutions:

    R: error installing packages UBUNTU - Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object Got message unable to load shared object stats.so when R starts

    Is there a way to solve this problem? Which may be the cause? What is the undefined symbol _ZSt24__throw_out_of_range_fmtPKcz?

  • elcortegano
    elcortegano about 6 years
    This solution also worked for me on a GNU/Linux system
  • Jeff Bezos
    Jeff Bezos over 2 years
    This will delete every package you've ever download in R
  • stevec
    stevec over 2 years
    @DanielFreeman that’s the point. Installing them again solved for me.