Search code examples
rdockerdockerfilerodbc

unexpected symbol in "install.packages(RODBC_1.2-6.tar.gz" when running in a dockerfile


I'm trying to install an old version of RODBC into my dockerfile (I'm using R 3.6.3 and the newest version of RODBC needs R v4) by downloading the package using curl and then installing using install.packages but I'm getting the below error. Any ideas of how to achieve this?

Error: unexpected symbol in "install.packages(RODBC_1.2-6.tar.gz"

In the dockerfile I try to do the above with the following RUN statements:

RUN curl https://cran.r-project.org/src/contrib/Archive/RODBC --output RODBC_1.2-6.tar.gz
RUN  R -e "install.packages(RODBC_1.2-6.tar.gz)" 

The full dockerfile is:

FROM ubuntu:bionic

RUN useradd docker \
        && mkdir /home/docker \
        && chown docker:docker /home/docker \
        && addgroup docker staff

RUN apt-get update \
        && apt-get install -y --no-install-recommends \
                software-properties-common \
                ed \
                less \
                locales \
                vim-tiny \
                wget \
                ca-certificates \
        && add-apt-repository --enable-source --yes "ppa:marutter/rrutter3.5" \
        && add-apt-repository --enable-source --yes "ppa:marutter/c2d4u3.5"

## Configure default locale, see https://github.com/rocker-org/rocker/issues/19
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
        && locale-gen en_US.utf8 \
        && /usr/sbin/update-locale LANG=en_US.UTF-8

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update \
        && apt-get install -y --no-install-recommends \
                 littler \
                 r-base \
                 r-base-dev \
                 r-recommended \
        && ln -s /usr/lib/R/site-library/littler/examples/install.r /usr/local/bin/install.r \
        && ln -s /usr/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \
        && ln -s /usr/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
        && ln -s /usr/lib/R/site-library/littler/examples/testInstalled.r /usr/local/bin/testInstalled.r \
        && install.r docopt \
        && rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
        && rm -rf /var/lib/apt/lists/*

RUN apt-get update
#These are all required, the exact version, for SQL Server to work
RUN apt-get install -y gnupg2 libssl1.0 libssl1.0-dev apt-transport-https

RUN apt-get install -y libcurl4-openssl-dev curl

RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc unixodbc-dev

RUN apt-get install -y libssl-dev

RUN install.r tidyr bigrquery dplyr sqldf readr httr uuid
RUN curl https://cran.r-project.org/src/contrib/Archive/RODBC --output RODBC_1.2-6.tar.gz
RUN  R -e "install.packages(RODBC_1.2-6.tar.gz)" 
COPY src/upload_v2.r /usr/local/src/scripts/upload_v2.r
WORKDIR /usr/local/src/scripts

Solution

  • It looks like quote is missing in RUN R line:

    RUN curl https://cran.r-project.org/src/contrib/Archive/RODBC --output RODBC_1.2-6.tar.gz
    RUN R -e "install.packages('RODBC_1.2-6.tar.gz')"