R unable to load dplyr

时光总嘲笑我的痴心妄想 提交于 2021-02-05 08:11:50

问题


I'm running from Ubuntu 16, using R version 3.4.1. I have dplyr installed and can load it when either I am running from RStudio or when I sudo into R from the terminal. However, if I run R without root permission, I cannot load dplyr due to the following error:

Error: package or namespace load failed for ‘dplyr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '<user-directory>/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs/Rcpp.so':
<user-directory>/anaconda3/lib/R/bin/exec/../../lib/../.././libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by <user-directory>/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs/Rcpp.so)

(where above I've replaced the /home/MY_USER_NAME dir with <user-directory> for some mild anonymization). I've seen a couple posts that may be tangentially related, but none of those remedies worked for me.

I'm curious if the fix is something as simple as changing permissions or ownership of certain files, or if the issue is that the search for GLIBCXX_3.4.20 is directed into my anaconda3 directory (when not root?!)?

Thank you in advance for any insights!

Edit: This may be an issue from a more base level with my installation of R. Often I install packages using install.packages(...) within RStudio, but on occasion this results in an error that is overcome by installing with install.packages(...) after entering R as root. This was the case with both dplyr and Rcpp. I.e., the versions which I have just reinstalled were done so as

> sudo R
> install.packages( 'Rcpp', dependencies = T )
> install.packages( 'dplyr', dependencies = T )

回答1:


Please make your question useful and understandable by stating how you installed these packages.

They come both from Ubuntu ie sudo apt-get install r-cran-dplyr will get a working version, and from CRAN ie install.r dplyr will too (here using my install.r from littler, use other wrappers to install.packages() at your leisure).

Sometimes your underlying libraries change so my first bet would be to simply reinstall Rcpp and then dplyr.

Your reference to /home suggests you installed from source, but as root. That is a bad idea. There a number of other questions answered here on the site about when/where/how apt-get may (or may not) be preferable so I don't need to repeat this.

Edit: In response to your edit:

  1. Never ever do sudo R. You want to write to /usr/local/lib/R/site-library and for that you can 1.a) add yourself to the group owning that directory or 1.b) make it owned by your group if it is just you on that machine.
  2. You could just do install.packages(c("Rcpp", "dplyr")) but you don't even need that as dplyr depends on Rcpp.
  3. Why not use the prebuild package? Remove what you have (ie sudo R CMD REMOVE Rcpp and ditto for dplyr, then do sudo apt-get install r-cran-dplyr


来源:https://stackoverflow.com/questions/47597789/r-unable-to-load-dplyr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!