MagicPossum
MagicPossum

Reputation: 311

R App in Docker Container: Unable to download PDF report (Error: No such file or directory) Knitr/Rmarkdown

I have been building a docker container for an R application and have continually run into an error with downloading a PDF report. The PDF report function works fine in R on a local machine, but when containerized, it throws the error below. I have tried forcing the install of specific packages, namely Knitr and Rmarkdown as other questions have mentioned, however it is still showing the same error. The file in Chrome downloads simply says "Failed - Server Problem". I have tested the download of a CSV file using the app, which works fine, therefore I believe it's an issue with generating and downloading a markdown PDF report.

I have included the build Dockerfile to assist. Any suggestions would be amazing!

Thanks!

DOCKERFILE:

FROM openanalytics/r-base

MAINTAINER ________

# system libraries of general use
RUN apt-get update && apt-get install -y \
    sudo \
    pandoc \
    pandoc-citeproc \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev \
    libxml2-dev \
    libssl1.0.0 \
    libpq-dev \
    git \
    texlive-full \
    html-xml-utils \
    libv8-3.14-dev

# system library dependency for the app

RUN apt-get update

# install packages for R

RUN R -e "install.packages(c('hms','devtools'), repos='https://cloud.r- 
project.org/')"

RUN R -e "require(devtools)"

RUN R -e "install.packages(c('car'), repos='https://cloud.r-project.org/')"

RUN R -e "devtools::install_version('readxl', version = '1.0.0', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('DT', version = '0.2', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('shinydashboard', version = '0.6.1', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('knitr', version = '1.18', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('magrittr', version = '1.5', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('ggrepel', version = '0.7.0', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('dplyr', version = '0.7.4', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('Rcpp', version = '0.12.14', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('rhandsontable', version = '0.3.4', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('shinyjs', version = '0.9.1', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('V8', version = '1.5', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('data.table', version = '1.10.4-3', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('packrat', version = '0.4.8-1', 
repos='https://cloud.r-project.org/')"
RUN R -e "devtools::install_version('zoo', version = '1.8-1', 
repos='https://cloud.r-project.org/')"
RUN R -e "install.packages('shiny', repos='https://cloud.r-project.org/')"
RUN wget https://github.com/rstudio/rmarkdown/archive/v1.8.tar.gz
RUN R CMD INSTALL v1.8.tar.gz
RUN R -e "install.packages('xml2', repos='https://cloud.r-project.org/')"
RUN R -e "install.packages('rvest', repos='https://cloud.r-project.org/')"
RUN wget https://cran.r- 
project.org/src/contrib/Archive/kableExtra/kableExtra_0.3.0.tar.gz
RUN R CMD INSTALL kableExtra_0.3.0.tar.gz

# copy the app to the image
RUN mkdir /root/tsk
COPY tsk /root/tsk

COPY Rprofile.site /usr/lib/R/etc/

EXPOSE 3838

CMD ["R", "-e", "shiny::runApp('/root/tsk')"]

ERROR FROM DOCKER:

Listening on http://0.0.0.0:3838
Warning in normalizePath(path, winslash = winslash, mustWork = mustWork) :
  path[1]="/tmp/RtmpMu8ezy/TSK.Rmd": No such file or directory
Warning: Error in tools::file_path_as_absolute: file '/tmp/RtmpMu8ezy/TSK.Rmd' 
does not exist
  [No stack trace available]
Warning in normalizePath(path, winslash = winslash, mustWork = mustWork) :
  path[1]="/tmp/RtmpMu8ezy/TSK.Rmd": No such file or directory
Warning: Error in tools::file_path_as_absolute: file '/tmp/RtmpMu8ezy/TSK.Rmd' 
does not exist
  [No stack trace available]
Warning in normalizePath(path, winslash = winslash, mustWork = mustWork) :
  path[1]="/tmp/RtmpMu8ezy/TSK.Rmd": No such file or directory
Warning: Error in tools::file_path_as_absolute: file '/tmp/RtmpMu8ezy/TSK.Rmd' 
does not exist
  [No stack trace available]

Upvotes: 1

Views: 897

Answers (1)

MagicPossum
MagicPossum

Reputation: 311

Simply changing the filename CASE from tsk.Rmd to TSK.Rmd - reason for this is that testing was always on OSX in an IDE which didn't throw any errors, however when building a container with Ubuntu which is case sensitive, it was unable to find the markdown file.

When building with different operating systems, be sure to check if the system is case sensitive! An easy mistake!

Upvotes: 2

Related Questions