R不接用户库 [英] R not picking up user library
问题描述
我有一个带有R 3.6.0的Fedora 30系统,并且用户库在Renviron
中设置为此:
I have a Fedora 30 system with R 3.6.0 and the user library is set in Renviron
as this one:
R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-redhat-linux-gnu-library/3.6'}
实际上,它显示在交互式R会话中:
And indeed it shows up in an interactive R session:
> Sys.getenv('R_LIBS_USER')
[1] "~/R/x86_64-redhat-linux-gnu-library/3.6"
> .libPaths()
[1] "/home/mu/R/x86_64-redhat-linux-gnu-library/3.6"
[2] "/usr/lib64/R/library"
[3] "/usr/share/R/library"
> .Library
[1] "/usr/lib64/R/library"
> .Library.site
[1] "/usr/lib64/R/library" "/usr/share/R/library"
但是我还有一个Debian 10系统,在/etc/Renviron
中我几乎完全相同:
But then I also have a Debian 10 system where in the /etc/Renviron
I have pretty much exactly the same line:
R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.5'}
但是,尽管存在环境变量,但它没有显示在我的图书馆搜索路径中:
But it does not show up on my library search path, though the environment variable is there:
> Sys.getenv('R_LIBS_USER')
[1] "~/R/x86_64-pc-linux-gnu-library/3.5"
> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"
[3] "/usr/lib/R/library"
> .Library
[1] "/usr/lib/R/library"
> .Library.site
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"
[3] "/usr/lib/R/library"
当我安装软件包时,它也建议安装到该库中,但随后找不到它们并崩溃,请参见
When I install packages it also suggests to install into that library, but then it does not find them and crashes, see this other question. What is missing for this directory to also make it into the library path?
推荐答案
如果您有~/.Renviron
,它可能会覆盖内容.而且,如果您有一个~/.Rprofile
可以使用不存在的目录对.libPaths
进行调用,那么您的搜索路径中都不会包含它们.
If you have a ~/.Renviron
, it might overwrite things. And if you have a ~/.Rprofile
which does a call to .libPaths
with a non-existant directory you will have neither of them in your search path.
这篇关于R不接用户库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!