rstudio / httpuv

HTTP and WebSocket server package for R
Other
227 stars 86 forks source link

Error Installing httpuv on docker alpine 3.12 #280

Closed usamaa9 closed 2 years ago

usamaa9 commented 4 years ago

I get an error when trying to install httpuv to my docker container based on an alpine 3.12 image

make --directory=libuv \
        HAVE_DTRACE=0
make[1]: Entering directory '/tmp/RtmpomCKmc/R.INSTALLe273c6e03ca/httpuv/src/libuv'
 cd . && /bin/sh /tmp/RtmpomCKmc/R.INSTALLe273c6e03ca/httpuv/src/libuv/missing automake-1.16 --foreign
configure.ac:21: error: version mismatch.  This is Automake 1.16.2,
configure.ac:21: but the definition used by this AM_INIT_AUTOMAKE
configure.ac:21: comes from Automake 1.16.1.  You should recreate
configure.ac:21: aclocal.m4 with aclocal and run automake again.
WARNING: 'automake-1.16' is probably too old.
         You should only need it if you modified 'Makefile.am' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'automake' program is part of the GNU Automake package:
         <https://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <https://www.gnu.org/software/autoconf>
         <https://www.gnu.org/software/m4/>
         <https://www.perl.org/>
make[1]: *** [Makefile:1471: Makefile.in] Error 1
make[1]: Leaving directory '/tmp/RtmpomCKmc/R.INSTALLe273c6e03ca/httpuv/src/libuv'
make: *** [Makevars:73: libuv/.libs/libuv.a] Error 2
ERROR: compilation failed for package ‘httpuv’
* removing ‘/usr/lib/R/library/httpuv’

The downloaded source packages are in
        ‘/tmp/RtmpmFIjab/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("httpuv") :
  installation of package ‘httpuv’ had non-zero exit status

This automake issue seems to have been identified before here and here. I can't however find a work around for this.

ZackBarry commented 4 years ago

Were you able to resolve this? Running into the same issue.

ZackBarry commented 4 years ago

I was able to install httpuv by installing autconf-2.69-r2 and automake-1.16.1-r0. Since automake-1.16.1-r0 is available for alpine 3.11, not 3.12, I had to add it to the list of repositories directly:

# Older version of automake required for R package httpuv
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.11/main' >> /etc/apk/repositories

# Download R and system dependencies
RUN set -ex; \
    apk add --no-cache \
    autoconf=2.69-r2 \
    automake=1.16.1-r0 
wch commented 4 years ago

@ZackBarry I see you're using Docker. Can you provide a Dockerfile to reproduce the issue?

ZackBarry commented 4 years ago

Unfortunately I didn't checkpoint my initial Dockerfile, but I did try the solution from a thread that references a similar issue (https://github.com/r-lib/fs/issues/210).

FROM alpine:3.12

RUN apk add --no-cache \
    autoconf=2.69-r2 \
    automake=1.16.2-r0 \
    build-base=0.5-r2 \
    R=3.6.3-r2 \
    R-dev=3.6.3-r2 && \
  apk add --no-cache --virtual .build-deps \
    wget=1.20.3-r1 && \
  apk del .build-deps

RUN mkdir -p /usr/share/doc/R/html

RUN R -e "install.packages('httpuv', repos=c(CRAN='https://cran.rstudio.com'))"

CMD ["/bin/bash", "-c"]

This results in the same error mentioned above:

cp -p -f libuv/m4/lt_obsolete.m4 libuv/m4/lt~obsolete.m4
(cd libuv \
    && touch aclocal.m4 \
    && touch -r aclocal.m4 configure Makefile.in \
    && chmod +x configure \
    && CC="gcc" CFLAGS="-Os -fomit-frame-pointer  -fpic -fvisibility=hidden" AR="ar" RANLIB="ranlib" LDFLAGS="-Wl,--as-needed" ./configure "--quiet")
make --directory=libuv \
    HAVE_DTRACE=0
make[1]: Entering directory '/tmp/RtmpDPcloN/R.INSTALL1ad3752ba89/httpuv/src/libuv'
 cd . && /bin/sh /tmp/RtmpDPcloN/R.INSTALL1ad3752ba89/httpuv/src/libuv/missing automake-1.16 --foreign
configure.ac:21: error: version mismatch.  This is Automake 1.16.2,
configure.ac:21: but the definition used by this AM_INIT_AUTOMAKE
configure.ac:21: comes from Automake 1.16.1.  You should recreate
configure.ac:21: aclocal.m4 with aclocal and run automake again.
WARNING: 'automake-1.16' is probably too old.
         You should only need it if you modified 'Makefile.am' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'automake' program is part of the GNU Automake package:
         <https://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <https://www.gnu.org/software/autoconf>
         <https://www.gnu.org/software/m4/>
         <https://www.perl.org/>
make[1]: *** [Makefile:1471: Makefile.in] Error 1
make[1]: Leaving directory '/tmp/RtmpDPcloN/R.INSTALL1ad3752ba89/httpuv/src/libuv'
make: *** [Makevars:73: libuv/.libs/libuv.a] Error 2
ERROR: compilation failed for package ‘httpuv’
* removing ‘/usr/lib/R/library/httpuv’
Fazendaaa commented 3 years ago

Had the same issue, fixed by using the solution provided by @ZackBarry and this answer put together:

RUN [  "apk", "add", "--no-cache", "--update-cache", \
        "--repository", "http://nl.alpinelinux.org/alpine/v3.11/main", \
        "autoconf=2.69-r2", \
        "automake=1.16.1-r0" \
]
vikram-rawat commented 3 years ago

I have the same issue with an Alpine docker image. but when I try to install httpuv package it doesn't produce an error it just hangs there for hours and do nothing. like this.

image

I checked both the examples from the issues and blindly copied the statements on my docker file... but none of it helped me. This is my dockerfile

FROM rhub/r-minimal:latest

RUN apk update && \
    apk add libcurl && \
    apk add g++ && \
    apk add gcc && \
    apk add linux-headers && \
    apk add gfortran && \
    apk add automake libtool m4 autoconf linux-headers && \
    apk add openssl

RUN apk add --no-cache \
    autoconf=2.69-r2 \
    automake=1.16.2-r0 \
    build-base=0.5-r2 \
    R=3.6.3-r2 \
    R-dev=3.6.3-r2 && \
    apk add --no-cache --virtual .build-deps \
    wget=1.20.3-r1 && \
    apk del .build-deps

WORKDIR /roulette_shiny
COPY . .

RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org')); \
    install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org')); \
    renv::restore(repos = c(CRAN = 'https://cloud.r-project.org')); \
    renv::clean();"

EXPOSE 9090
CMD ["Rscript", "-e", "shiny::runApp('app.R', host = '0.0.0.0', port = 9090, launch.browser = FALSE);"]

Please let me know if there is something I am not doing correctly here.

andrei-dascalu commented 3 years ago

Same issue here (but on alpine 3.13). I also can't forcibly install automake 1.16.1 as apk says it will break (world).

MrMarvin commented 3 years ago

One noteworthy observation, maybe: When downloading, unpacking and manually building the src/libuv/ part of the package everything works out on newer alpine versions. This is on 3.14 right now.

bash-5.1# tar xzf httpuv_1.6.1.tar.gz
bash-5.1# cd httpuv/src/libuv/
bash-5.1# ./configure
[...]
bash-5.1# make; echo $?
[...]
0

If now bundling this package back together

bash-5.1# cd ../../..
bash-5.1# ls
httpuv
bash-5.1# R CMD build httpuv/
* checking for file ‘httpuv/DESCRIPTION’ ... OK
* preparing ‘httpuv’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘httpuv_1.6.1.tar.gz’
* 

it can be locally installed without the above error using bash-5.1# R CMD INSTALL httpuv_1.6.1.tar.gz. It's still compiling libuv, but this time completes just fine.

I am not very familiar with the C building tools ecosystem, and - full disclosure - never understood how automake works, but it seems to me this is a situation where we do not properly configure the Makefile. Probably some tweaks around here https://github.com/rstudio/httpuv/blob/13bcd461e4228583b29e63d4eae8ad6bb00a4ab0/src/Makevars#L53-L70

myersjustinc commented 3 years ago

Confirming what others have said: In my Alpine 3.14 installation on aarch64 (under Termux on Android), this installs the correct autotools versions and allows install.packages("httpuv") to succeed:

# apk add \
    --no-cache \
    --repository=http://dl-cdn.alpinelinux.org/alpine/v3.11/main \
    autoconf=2.69-r2 \
    automake=1.16.1-r0
jcheng5 commented 3 years ago

@wch This all appears to stem from us suppressing autoconf from running at install time. https://github.com/rstudio/httpuv/blob/d49580349c5845022790054d9e27a3f28010336b/src/Makevars#L67-L68

Maybe we can make this conditional, so Alpine users can override this? Or else automatically enable for Alpine, or automatically enable if autoconf/automake are installed?

wch commented 3 years ago

@jcheng5 I can't remember exactly why running autotools was problematic and we went to lengths to prevent it. Here are some relevant references:

https://github.com/rstudio/httpuv/issues/124 https://github.com/rstudio/httpuv/commit/98f4b367712c0b84fa95aac025c267c5912b05a2 https://github.com/rstudio/httpuv/commit/aed7b987e2962d409fcad424567e0b2f096a90f3

In #124, I think the problem was that the system version of automake was older than the one used to generate the committed files. And I suppose it would be a problem if someone tried to run autotools if it wasn't installed on their system.

So maybe we should re-run it if (A) autotools is installed and (B) it's the same or newer version that was used to generate the files committed to httpuv?