简体   繁体   English

为 Mac 创建 R 的便携式版本(并为此版本从源安装 package)

[英]Creating a portable version of R for Mac (and installing package from source for this version)

I am trying to create a completely portable version of R for Mac that I can send to users with no R on their system and they can essentially double click a command file and it launches a Shiny application.我正在尝试为 Mac 创建一个完全可移植的 R 版本,我可以将其发送给系统上没有 R 的用户,他们基本上可以双击命令文件并启动 Z3E751ABE1B5D0232F0232F08CF279ADZ7A 应用程序。 I'll need to be able to install packages including some built from source (and some from GitHub).我需要能够安装包,包括一些从源代码构建的包(还有一些来自 GitHub)。

I am using the script from this GitHub repository ( https://github.com/dirkschumacher/r-shiny-electron/blob/master/get-r-mac.sh ) as a starting point (it's also pasted below), creating a version of R, but (A) I find that when I try to launch R it gives me an error not finding etc/ldpaths and (B) when I try to launch Rscript it runs my system version -- I run `Rscript -e 'print(R.version)' and it prints out 4.0 which is my system version of R rather than the version 3.5.1 which the shell script has downloaded and processed.我使用来自这个 GitHub 存储库( https://github.com/dirkschumacher/r-shiny-electron/blob/master/get-r-mac.sh )的脚本作为起点(它也粘贴在下面),创建R 的一个版本,但是(A)我发现当我尝试启动 R 时,它给了我一个错误,找不到 etc/ldpaths 和(B)当我尝试启动 Rscript 它运行我的系统版本 - 我运行`Rscript - e 'print(R.version)' 并打印出 4.0,这是我的 R 的系统版本,而不是 shell 脚本已下载和处理的版本 3.5.1。

I've experimented with editing the "R" executable and altering R_HOME and R_HOME_DIR but it still runs into issues when I try to install packages to the 3.5.1 directory.我已经尝试编辑“R”可执行文件并更改 R_HOME 和 R_HOME_DIR,但是当我尝试将软件包安装到 3.5.1 目录时它仍然遇到问题。

Can anyone provide some guidance?任何人都可以提供一些指导吗?

(By the way docker is not an option, this needs to be as simple as possible end-users with limited technical skills. So having them install docker etc won't be an option) (顺便说一句,docker 不是一个选项,这需要尽可能简单的技术技能的最终用户。所以让他们安装 docker 等将不是一个选项)

#!/usr/bin/env bash
set -e

# Download and extract the main Mac Resources directory
# Requires xar and cpio, both installed in the Dockerfile
mkdir -p r-mac
curl -o r-mac/latest_r.pkg \
     https://cloud.r-project.org/bin/macosx/R-3.5.1.pkg

cd r-mac
xar -xf latest_r.pkg
rm -r r-1.pkg Resources tcltk8.pkg texinfo5.pkg Distribution latest_r.pkg
cat r.pkg/Payload | gunzip -dc | cpio -i
mv R.framework/Versions/Current/Resources/* .
rm -r r.pkg R.framework

# Patch the main R script
sed -i.bak '/^R_HOME_DIR=/d' bin/R
sed -i.bak 's;/Library/Frameworks/R.framework/Resources;${R_HOME};g' \
    bin/R
chmod +x bin/R
rm -f bin/R.bak

# Remove unneccessary files TODO: What else
rm -r doc tests
rm -r lib/*.dSYM

Happy to help you get this working for your shiny app.很高兴帮助您为您的 shiny 应用程序工作。 You can use this github repo for Electron wrapping R/Shiny... just clone, and replace the app.R (for your other packages you need to install them in the local R folder after cloning and then running R from the command line out of the R-Portable-Mac/bin folder... You can use this github repo for Electron wrapping R/Shiny... just clone, and replace the app.R (for your other packages you need to install them in the local R folder after cloning and then running R from the command line out R-Portable-Mac/bin 文件夹的...

Try it with the Hello World app.R that is included first尝试使用首先包含的 Hello World app.R

https://github.com/ColumbusCollaboratory/electron-quick-start https://github.com/ColumbusCollaboratory/electron-quick-start

And, then installing your packages in the local R-Portable-Mac folder runtime.然后在本地 R-Portable-Mac 文件夹运行时安装你的包。 Included packages by default... https://github.com/ColumbusCollaboratory/electron-quick-start/tree/master/R-Portable-Mac/library Your packages will show up here after install.packages() from the command line using the local R-Mac-Portable runtime.默认情况下包含的包... https://github.com/ColumbusCollaboratory/electron-quick-start/tree/master/R-Portable-Mac/library您的包将在命令行 install.packages() 之后显示在这里使用本地 R-Mac-Portable 运行时。

We have been working on a R Addin for this also... https://github.com/ColumbusCollaboratory/photon我们一直在为此开发一个 R 插件...... https://github.com/ColumbusCollaboratory/photon

But, note the add-in is still a work in progress and doesn't work with compiled R packages;但是,请注意该插件仍在开发中,不适用于已编译的 R 包; still have to go into the local R folder and runtime on the command line and install the packages directly into the local R folder libpath as discussed above.仍然必须将 go 放入本地 R 文件夹和运行时在命令行中,并将软件包直接安装到本地 R 文件夹 libpath 中,如上所述。

Give it a try and let us know through Github issues if you have any questions and issues.试一试,如果您有任何疑问和问题,请通过 Github 问题告诉我们。 And, if you've already posted out there, sorry we haven't responded as of yet.而且,如果您已经在那里发帖,很抱歉我们还没有回复。 Would love to communicate through the photon Add-In for this to get it working with compiling packages (into the libPath)--if you have the time to help.很想通过光子插件进行交流,以使其与编译包(进入 libPath)一起工作——如果你有时间帮忙的话。 Thanks!谢谢!

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

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