R 3.4.1“单烛光”个人库路径错误:无法创建“NA”

时间:2023-01-16 23:40:21

I just updated to R (3.4.1 "Single Candle") on my Linux Mint 18.1 Cinnamon machine and I attempted to install a package. R returned the following:

我刚刚在我的Linux Mint 18.1肉桂机上更新了R(3.4.1“Single Candle”),并尝试安装一个软件包。R返回以下:

> install.packages('ggplot2')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("ggplot2") :
  'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead?  (y/n) y
Would you like to create a personal library
NA
to install packages into?  (y/n) y
Error in install.packages("ggplot2") : unable to create ‘NA’

I have encountered the 'lib not writable' output before but typically it offers a solution like this one:

我以前遇到过“lib不可写”的输出,但通常它提供了这样的解决方案:

Would you like to create a personal library
~/R/x86_64-pc-linux-gnu-library/3.4
to install packages into?  (y/n) y 

Any ideas why the personal library is suggesting NA? Is there a way to manually override this?

为什么个人图书馆在暗示着NA?有没有一种方法可以手动重写这个?

6 个解决方案

#1


3  

After July 8, 2017 this will resolve all problems

2017年7月8日以后,这将解决所有问题。

sudo apt-get update

#2


12  

I don't know what's causing this problem (i'm also experiencing it on Ubuntu 16.04), but here's a quick workaround:

我不知道是什么导致了这个问题(我也在Ubuntu 16.04上体验过),但这里有一个快速的解决方案:

.libPaths(c("/home/your_username/R/x86_64-pc-linux-gnu-library/3.4/", .libPaths()))

Of course, you can replace "/home/your_username/..." for any another directory (that will store your personal library).

当然,您可以将“/home/your_username/…”替换为任何其他目录(将存储您的个人库)。

This solution makes install.packages() and library() work. Waiting for a full fix!

此解决方案生成install.packages()和library()工作。等待完全修复!

EDIT: I should note that this solution is not persistent. That is, it won't last after restarting R. You can fix this by adding the same line of code described above to the /home/your_username/.Rprofile file.

编辑:我应该注意到这个解决方案不是持久的。也就是说,在重新启动r后不会持久。您可以通过将上面描述的代码行添加到/home/your_username/中来修复这个问题。Rprofile文件。

#3


11  

Looking at the details in @Dirk 's comment (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866768) this is a planned behaviour so that packages are installed once for all users of the system.

查看@Dirk的评论中的详细信息(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866768),这是一个有计划的行为,以便为系统的所有用户安装一次包。

The solution is to make /usr/local/lib/R/ writable for all users, rather than to re-instate the old behaviour of having a personal package library for every individual user.

解决方案是为所有用户创建/ usr/local/lib/r/writable,而不是重新定义为每个用户提供个人包库的旧行为。

Open up a terminal and:

打开终端:

  • Navigate to /usr/local/lib/ with cd /usr/local/lib/
  • 导航到/usr/local/lib/与cd /usr/local/lib/。
  • Change the owner:group so that all users can write to the folder. I happen to have a group on my computer that all users are a member of, so I used that, but see https://askubuntu.com/questions/66718/how-to-manage-users-and-groups for help with setting up a group if necessary
  • 更改所有者:组,以便所有用户都可以写入文件夹。我碰巧在我的计算机上有一个所有用户都是成员的组,所以我使用了这个组,但是如果有必要的话,可以看到https://askubuntu.com/questions/66718/howto - manageuser -groups来帮助建立一个组。
  • To change ownership use sudo chown owner:group -R R/. owner is an any user, it doesn't really matter. group is the key one; make sure anyone wanting to use R on your system is a member of this group. -R is recursive (i.e. do it to all files and folders in R/).
  • 变更所有权使用sudo chown owner:group -R R/。所有者是一个用户,这并不重要。团队是关键;确保任何想要在系统上使用R的人都是这个组的成员。-R是递归的(即对R/中所有的文件和文件夹执行)。
  • If you need to change group permissions, use chmod -R 775 R/. This gives the owner and group read, write, and execute permissions, and gives all others read and execute permissions.
  • 如果需要更改组权限,请使用chmod - r775 R/。这赋予所有者和组读、写和执行权限,并给予所有其他人读取和执行权限。

Now restart R and you should be able to install packages to your this shared location.

现在重新启动R,您应该能够将包安装到您的这个共享位置。

#4


10  

My solution was the following:

我的解决办法是:

In the file /usr/lib/R/etc/Renviron there is a configuration of R.

在文件/usr/ lib/r/etc/renvironment中有一个R的配置。

In lines 43-45 there is:

第43-45行有:

# edd Jun 2017  Comment-out R_LIBS_USER
#R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}
##R_LIBS_USER=${R_LIBS_USER-'~/Library/R/3.4/library'}

I have uncommented R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}, restarted RStudio and now it works.

我没有评论R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'},重新启动RStudio,现在它开始工作了。

EDIT: Looking at the comments, it seems like a planned behaviour. Here is another solution.

编辑:看看评论,看起来像是有计划的行为。这是另一个解决方案。

#5


0  

The same happened to me while running the installation procedure for some Bioconductor packages.

在运行一些生物导体包的安装过程时,也发生了同样的事情。

Then I realized also I could write this (or similar) on the bash command line:

然后我意识到我可以在bash命令行上写这个(或类似的):

export R_LIBS_USER=$HOME/R/x86_64-pc-linux-gnu-library/3.4 && R

出口R_LIBS_USER = $ HOME / R / x86_64-pc-linux-gnu-library / 3.4 & & R

or

export R_LIBS_USER=$HOME/R/x86_64-pc-linux-gnu-library/3.4 && rstudio

出口R_LIBS_USER = $ HOME / R / x86_64-pc-linux-gnu-library / 3.4 & & rstudio

and then run upgrade.packages() (or install.packages(), or biocLite()) inside R.

然后在R中运行upgrade.package()(或install.packages()或biocLite())。

This way the change is temporary, and you don't have to update any config files.

这种方式的更改是临时的,您不需要更新任何配置文件。

This shell command is useless if subsequently a command in .Renvironor.Rprofile` sets R_USER_LIBS to a different location during R startup (-check your configuration).

如果随后在. renvironment中执行命令,则该shell命令无效。Rprofile将R_USER_LIBS设置为R启动时的不同位置(-检查您的配置)。

Sticking with in $HOME/R/x86_64-pc-linux-gnu-library/3.X can be desirable if you have already lots of packages in this location, you want them upgraded/installed there. I have lots of Bioconductor packages in there, and I don't want them to download again, some of these packages download huge "Omics" datasets when used. Maybe the partition where /usr/local/lib/R resides has too little disk space or is on a slow drive.

坚持在$ HOME / R / x86_64-pc-linux-gnu-library / 3。如果您在这个位置已经有很多包,您希望它们在那里升级/安装。我在那里有很多的Bioconductor包,我不希望它们再次下载,其中一些包在使用时下载了巨大的“组学”数据集。也许/usr/local/lib/R所驻留的分区的磁盘空间太小,或者是在缓慢的驱动器上。

#6


0  

May be this is a bug of R 3.4.1, and my solution is change the line of

可能这是一个R 3.4.1的bug,我的解决方案是改变这条线?

R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'} 

in /etc/R/Renviron file into

在/etc/R/Renviron文件进

R_LIBS_SITE=${R_LIBS_SITE-'~/R/x86_64-pc-linux-gnu-library/3.4.1:/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}

#1


3  

After July 8, 2017 this will resolve all problems

2017年7月8日以后,这将解决所有问题。

sudo apt-get update

#2


12  

I don't know what's causing this problem (i'm also experiencing it on Ubuntu 16.04), but here's a quick workaround:

我不知道是什么导致了这个问题(我也在Ubuntu 16.04上体验过),但这里有一个快速的解决方案:

.libPaths(c("/home/your_username/R/x86_64-pc-linux-gnu-library/3.4/", .libPaths()))

Of course, you can replace "/home/your_username/..." for any another directory (that will store your personal library).

当然,您可以将“/home/your_username/…”替换为任何其他目录(将存储您的个人库)。

This solution makes install.packages() and library() work. Waiting for a full fix!

此解决方案生成install.packages()和library()工作。等待完全修复!

EDIT: I should note that this solution is not persistent. That is, it won't last after restarting R. You can fix this by adding the same line of code described above to the /home/your_username/.Rprofile file.

编辑:我应该注意到这个解决方案不是持久的。也就是说,在重新启动r后不会持久。您可以通过将上面描述的代码行添加到/home/your_username/中来修复这个问题。Rprofile文件。

#3


11  

Looking at the details in @Dirk 's comment (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866768) this is a planned behaviour so that packages are installed once for all users of the system.

查看@Dirk的评论中的详细信息(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866768),这是一个有计划的行为,以便为系统的所有用户安装一次包。

The solution is to make /usr/local/lib/R/ writable for all users, rather than to re-instate the old behaviour of having a personal package library for every individual user.

解决方案是为所有用户创建/ usr/local/lib/r/writable,而不是重新定义为每个用户提供个人包库的旧行为。

Open up a terminal and:

打开终端:

  • Navigate to /usr/local/lib/ with cd /usr/local/lib/
  • 导航到/usr/local/lib/与cd /usr/local/lib/。
  • Change the owner:group so that all users can write to the folder. I happen to have a group on my computer that all users are a member of, so I used that, but see https://askubuntu.com/questions/66718/how-to-manage-users-and-groups for help with setting up a group if necessary
  • 更改所有者:组,以便所有用户都可以写入文件夹。我碰巧在我的计算机上有一个所有用户都是成员的组,所以我使用了这个组,但是如果有必要的话,可以看到https://askubuntu.com/questions/66718/howto - manageuser -groups来帮助建立一个组。
  • To change ownership use sudo chown owner:group -R R/. owner is an any user, it doesn't really matter. group is the key one; make sure anyone wanting to use R on your system is a member of this group. -R is recursive (i.e. do it to all files and folders in R/).
  • 变更所有权使用sudo chown owner:group -R R/。所有者是一个用户,这并不重要。团队是关键;确保任何想要在系统上使用R的人都是这个组的成员。-R是递归的(即对R/中所有的文件和文件夹执行)。
  • If you need to change group permissions, use chmod -R 775 R/. This gives the owner and group read, write, and execute permissions, and gives all others read and execute permissions.
  • 如果需要更改组权限,请使用chmod - r775 R/。这赋予所有者和组读、写和执行权限,并给予所有其他人读取和执行权限。

Now restart R and you should be able to install packages to your this shared location.

现在重新启动R,您应该能够将包安装到您的这个共享位置。

#4


10  

My solution was the following:

我的解决办法是:

In the file /usr/lib/R/etc/Renviron there is a configuration of R.

在文件/usr/ lib/r/etc/renvironment中有一个R的配置。

In lines 43-45 there is:

第43-45行有:

# edd Jun 2017  Comment-out R_LIBS_USER
#R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}
##R_LIBS_USER=${R_LIBS_USER-'~/Library/R/3.4/library'}

I have uncommented R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}, restarted RStudio and now it works.

我没有评论R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'},重新启动RStudio,现在它开始工作了。

EDIT: Looking at the comments, it seems like a planned behaviour. Here is another solution.

编辑:看看评论,看起来像是有计划的行为。这是另一个解决方案。

#5


0  

The same happened to me while running the installation procedure for some Bioconductor packages.

在运行一些生物导体包的安装过程时,也发生了同样的事情。

Then I realized also I could write this (or similar) on the bash command line:

然后我意识到我可以在bash命令行上写这个(或类似的):

export R_LIBS_USER=$HOME/R/x86_64-pc-linux-gnu-library/3.4 && R

出口R_LIBS_USER = $ HOME / R / x86_64-pc-linux-gnu-library / 3.4 & & R

or

export R_LIBS_USER=$HOME/R/x86_64-pc-linux-gnu-library/3.4 && rstudio

出口R_LIBS_USER = $ HOME / R / x86_64-pc-linux-gnu-library / 3.4 & & rstudio

and then run upgrade.packages() (or install.packages(), or biocLite()) inside R.

然后在R中运行upgrade.package()(或install.packages()或biocLite())。

This way the change is temporary, and you don't have to update any config files.

这种方式的更改是临时的,您不需要更新任何配置文件。

This shell command is useless if subsequently a command in .Renvironor.Rprofile` sets R_USER_LIBS to a different location during R startup (-check your configuration).

如果随后在. renvironment中执行命令,则该shell命令无效。Rprofile将R_USER_LIBS设置为R启动时的不同位置(-检查您的配置)。

Sticking with in $HOME/R/x86_64-pc-linux-gnu-library/3.X can be desirable if you have already lots of packages in this location, you want them upgraded/installed there. I have lots of Bioconductor packages in there, and I don't want them to download again, some of these packages download huge "Omics" datasets when used. Maybe the partition where /usr/local/lib/R resides has too little disk space or is on a slow drive.

坚持在$ HOME / R / x86_64-pc-linux-gnu-library / 3。如果您在这个位置已经有很多包,您希望它们在那里升级/安装。我在那里有很多的Bioconductor包,我不希望它们再次下载,其中一些包在使用时下载了巨大的“组学”数据集。也许/usr/local/lib/R所驻留的分区的磁盘空间太小,或者是在缓慢的驱动器上。

#6


0  

May be this is a bug of R 3.4.1, and my solution is change the line of

可能这是一个R 3.4.1的bug,我的解决方案是改变这条线?

R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'} 

in /etc/R/Renviron file into

在/etc/R/Renviron文件进

R_LIBS_SITE=${R_LIBS_SITE-'~/R/x86_64-pc-linux-gnu-library/3.4.1:/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}