简体   繁体   English

R-如何设置闪亮服务器的install.packages()路径? -Ubuntu

[英]R - How to set the path of install.packages() for shiny server ? - Ubuntu

For my system: Ubuntu 12.04 and R 3.03 , whenever I install a custom package in R via 对于我的系统:每当我通过RR中安装自定义软件包时, Ubuntu 12.04R 3.03

>install.packages()

the package is installed by default to 该软件包默认安装为

/home/USER/R/x86_64-pc-linus-gnu-library/3.0/ 

as opposed to system-wide in 与系统范围内的

/usr/local/lib/R/site-library/

which is needed for shiny-server to work with that package. 闪亮服务器才能使用该软件包。

My temporary solution is to copy the packages to the correct folder after the fact. 我的临时解决方案是将程序包复制到正确的文件夹中。

Question: How can I set the default install path from the start to avoid this problem? 问题:如何从一开始就设置默认安装路径,以避免出现此问题?

Yes -- I consider this to be a misfeature and disable my per-user directory. 是的-我认为这是功能不当,并禁用了每个用户的目录。

Moreover, I mostly use a script install.r (of which a version is an example in the littler package you can install as part of Ubuntu) which simple explicitly set the /usr/local/lib/R/site-library directory as the default. 此外,我主要使用脚本install.r (该版本的示例可以作为Ubuntu的一部分安装在littler软件包中),该脚本简单地将/usr/local/lib/R/site-library目录设置为默认。 With a patch we got into R 3.0.2 or 3.0.3, normal user can write into the directory and will now create group-writeable directories so other users can update and overwrite -- just make everybody a member of the same group, say staff or admin . 使用我们加入R 3.0.2或3.0.3的补丁程序,普通用户可以写入目录,现在将创建可写组的目录,以便其他用户可以更新和覆盖-只需使每个人都属于同一组即可,例如staffadmin And then you don't even need sudo or root. 然后,您甚至不需要sudo或root。

I have essentially answered this same question a few times here over the years (minus the shiny angle, which is not really relevant) so feel free to search for the other for more details, examples, ... 多年来,我已经在这里多次回答了相同的问题(减去了发亮的角度,这并不是很重要),因此随时可以搜索其他详细信息,示例...

I would propose a different approach. 我会提出另一种方法。

The problem is that shiny-server cannot find the packages that you install because it runs them as a different user which is called shiny . 问题是Shiny-server找不到您安装的软件包,因为它以另一个用户身份运行它们,即所谓的shiny This user is created upon installation of shiny-server 该用户是在安装Shiny-server时创建的

The easiest (and safest IMHO) way to solve this is to just install the packages as the shiny user, using the following steps. 解决此问题的最简单(最安全的恕我直言)的方法是,按照以下步骤,以闪亮的用户身份安装软件包。

  1. Set a password for the user using sudo passwd shiny , now enter and confirm a password of your choosing. 使用sudo passwd shiny为用户设置密码,现在输入并确认您选择的密码。
  2. Switch to the shiny account using: su - shiny 使用以下命令切换到闪亮帐户: su - shiny
  3. Call up R using $ R (without sudo) 调用R使用$ R (没有sudo)
  4. Install the required packages, in this case: `install.packages("shinydashboard") 安装所需的软件包,在这种情况下:`install.packages(“ shinydashboard”)

Note that if you have rstudio-server installed on the same machine then you can perform steps 2-4 using that interface. 请注意,如果您在同一台计算机上安装了rstudio-server,则可以使用该界面执行步骤2-4。 Simply go the same domain/ip and use :8787 for the rstudio-server interface instead of :3838 for shiny-server. 只需转到相同的域/ ip,然后将:8787用于rstudio-server接口,而不是:3838用于Shiny-server。

Adapted from my answer here 这里我的答案改编

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM