闪亮的应用程序,闪亮的服务器 rmarkdown::render(),权限不正确?

时间:2021-06-10 12:05:07

标签: r shiny r-markdown shiny-server privileges

你好,stackoverflow 社区。 ,

我正在尝试通过闪亮的应用程序创建和呈现 .rmd 文件。

“在我的本地机器(ubuntu 18.04)上,这按预期工作。'

但是在我的服务器(Ubuntu 20.04.2 LTS)上,即使安装了所有依赖项,

它:

  • 当我尝试使用 file.create() 或 writeBin() 创建一个空文件时断开连接,
  • 在我尝试使用 cat() 更改文件内容时断开连接 ,
  • 在我尝试 rmarkdown:render() 文件时断开连接

我做了这个最小的reprex:

library(shiny)
library(base64enc)
ui <- fluidPage(

# Application title
titlePanel("renderRMD"),

# Sidebar 
sidebarLayout(
    sidebarPanel(
      h3("create an empty file:"),
      actionButton("rmd", "create an RMD"),
      h3("populate file"),
      textInput("title","add title",value = "Some Title"),
      textInput("txt","add text", value ="The docs content"),
      actionButton("sub", "submit Text and Title"),
      h3("render RMD:"),
      actionButton("render", "Render"),
      h3("View pdf"),
      actionButton("prev", "View pdf")
    ),
    
    # Show the pdf:
    mainPanel(
      uiOutput("pdf")
        )
     )
  )

# Define server logic
server <- function(input, output) {
  
# create an empty rmd
    observeEvent(input$rmd, {
      file.create("www/test.rmd")
    })
  
# populate file 
    observeEvent(input$sub,{
      cat(
        paste("---","\ntitle:",
              input$title,
              '\nauthor: "Author"\noutput: pdf_document\n---\n',
              input$txt),
          file= "www/test.rmd")
    })
    
# render file:  
    observeEvent(input$render,{
      rmarkdown::render(input = "www/test.rmd")
    })
    
#  View pdf:
    observeEvent(input$prev, {   
      output$pdf <- renderUI({
        pdf_file_path <- "www/test.pdf"
        b64 <- dataURI(file = pdf_file_path, mime = "application/pdf")
        tags$iframe(
          style = "height: 600px; width: 100%;", src = b64
        )
      })
    })
}

# Run the application 
shinyApp(ui = ui, server = server)

这是 Shine-server 开源版本的限制,还是可能与 linux 上的权限有关?

更新:

$ sudo chown -R shiny:shiny ./www

修复了 file.create 和 cat() 的权限 , 然而 render() 仍然不起作用:

感谢您的建议!

0 个答案:

没有答案