![在 R 中从 Shiny 应用 runApp() 时与 Firefox 的连接失败](https://linux22.com/image/928940/%E5%9C%A8%20R%20%E4%B8%AD%E4%BB%8E%20Shiny%20%E5%BA%94%E7%94%A8%20runApp()%20%E6%97%B6%E4%B8%8E%20Firefox%20%E7%9A%84%E8%BF%9E%E6%8E%A5%E5%A4%B1%E8%B4%A5.png)
我正在按照说明进行闪亮的教程https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/
在某个时候我必须运行示例应用程序。示例应用程序存储在文件夹中在/usr/local/lib/R/站点库/shiny/示例/01_hello我想在终端中运行它。所以我输入
sudo -i R # entering my password so that R is being started
library(shiny)
runApp("/usr/local/lib/R/site-library/shiny/examples/01_hello")
但它不起作用。
我的控制台给出了以下错误消息:
Listening on http://127.0.0.1:3530
Running Firefox as root in a
regular user's session is not supported. ($XAUTHORITY is
/run/user/1000/gdm/Xauthority which is owned by tobias.)
Running
Firefox as root in a regular user's session is not supported.
($XAUTHORITY is /run/user/1000/gdm/Xauthority which is owned by
tobias.)
Running Firefox as root in a regular user's session is not
supported. ($XAUTHORITY is /run/user/1000/gdm/Xauthority which is
owned by tobias.)
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: iceweasel: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: seamonkey: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: mozilla: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: epiphany: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: konqueror: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: google-chrome: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: elinks:not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'http://127.0.0.1:3530'
这里不支持在普通用户会话中以 root 身份运行 Firefox。($XAUTHORITY 是 /run/user/1000/gdm/Xauthority,由 radix 拥有。)我发现了 Firefox 问题,但与 R 无关......
我的目的是输入后runApp()
,Firefox 会分别打开一个新选项卡并显示 Shiny 应用程序,以便我可以与其进行交互。
另外,我必须说,我是 ubuntu 的新手 - 所以在回答我的问题时请记住这一点。提前谢谢!
答案1
Shiny 使用高范围(>1024)的 TCP 端口,因此您不需要sudo
在这里。
以有权访问 Xorg 的普通用户身份执行所有命令:
R
library(shiny)
runApp("/usr/local/lib/R/site-library/shiny/examples/01_hello")