rocker-org / rocker

R configurations for Docker
https://rocker-project.org
GNU General Public License v2.0
1.45k stars 273 forks source link

could not install curl on rocker #425

Closed vikram-rawat closed 3 years ago

vikram-rawat commented 3 years ago

I am new to docker and I was trying to write a shinyapp on docker. This is my dockerfile

FROM rocker/r-base
RUN apt-get update && \
    apt-get install -y libpq-dev && \
    # apt-get libcurl4-openssl-dev
    # apt-get -t testing install curl
    # apt-get install -t unstable curl
    # apt-get install -t unstable libcurl4
    apt-get install libcurl4

WORKDIR /roulette_shiny
COPY . .

RUN R -e "install.packages('curl', repos = c(CRAN = 'https://cloud.r-project.org'), type = 'source');"

I went through google and tried every possible combination of installing libcurl I could. I even read the dockerfile of rocker/r-ver and used that statement to install libcurl. I guess there is something else that I am missing. This is the error I get

* installing *source* package ‘curl’ ...
** package ‘curl’ successfully unpacked and MD5 sums checked
** using staged installation
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lcurl
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘curl’
* removing ‘/roulette_shiny/renv/library/R-4.0/x86_64-pc-linux-gnu/curl’

The downloaded source packages are in
        ‘/tmp/RtmpPKX5KE/downloaded_packages’
Warning message:
In (function (pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos,  :
  installation of package ‘curl’ had non-zero exit status
> 

Please guide me through

eddelbuettel commented 3 years ago

Can you explain exactly what you were trying to do?

There are two packages named curl: One is a binary you would install via apt install curl. The other is a CRAN package, sadly with the same name leading to this confusion, which you would install most easily as a prebuilt binary with apt instal r-cran-curl.

Does either of these two satisfy your needs?

eddelbuettel commented 3 years ago

Otherwise, if you insist on installing from CRAN, it really is as easy as following Jeroen's suggestion. I have no idea why you think libpq-dev would have any bearing on this.

Session log:

edd@rob:~$ docker run --rm -ti r-base bash
root@e17b9ecae221:/# apt update -qq                           # -qq to make it silent     
20 packages can be upgraded. Run 'apt list --upgradable' to see them.     
root@e17b9ecae221:/# apt install libcurl4-openssl-dev          
Suggested packages: 
libcurl4-doc libidn11-dev libkrb5-dev libldap2-dev librtmp-dev libssh2-1-dev libssl-dev        
The following NEW packages will be installed:       
libcurl4-openssl-dev    
0 upgraded, 1 newly installed, 0 to remove and 20 not upgraded.                  
Need to get 425 kB of archives.    
After this operation, 1,576 kB of additional disk space will be used.   
debconf: delaying package configuration, since apt-utils is not installed   
Selecting previously unselected package libcurl4-openssl-dev:amd64.        
(Reading database ... 18085 files and directories currently installed.)       
Preparing to unpack .../libcurl4-openssl-dev_7.72.0-1_amd64.deb ...      
Unpacking libcurl4-openssl-dev:amd64 (7.72.0-1) ...                  
Setting up libcurl4-openssl-dev:amd64 (7.72.0-1) ...     
root@e17b9ecae221:/# install.r curl               
trying URL 'https://cloud.r-project.org/src/contrib/curl_4.3.tar.gz'                   
Content type 'application/x-gzip' length 673779 bytes (657 KB)  
==================================================      
downloaded 657 KB    

 * installing *source* package ‘curl’ ...              
** package ‘curl’ successfully unpacked and MD5 sums checked           
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/x86_64-linux-gnu                                                         
Using PKG_LIBS=-lcurl
** libs                    
rm -f curl.so callbacks.o curl.o download.o escape.o fetch.o form.o getdate.o handle.o ieproxy.o init.o interrupt.o multi.o nslookup.o reflist.o split.o ssl.o typechecking.o utils.o version.o winidn.o writer.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-s
trong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c callbacks.c -o callbacks.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-s
trong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c curl.c -o curl.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-s
trong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c download.c -o download.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-s
trong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c escape.c -o escape.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c fetch.c -o fetch.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c form.c -o form.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c getdate.c -o getdate.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c handle.c -o handle.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c ieproxy.c -o ieproxy.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c interrupt.c -o interrupt.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c multi.c -o multi.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c nslookup.c -o nslookup.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c reflist.c -o reflist.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c split.c -o split.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c ssl.c -o ssl.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c typechecking.c -o typechecking.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c utils.c -o utils.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c version.c -o version.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c winidn.c -o winidn.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/x86_64-linux-gnu -DSTRICT_R_HEADERS    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oKyfjH/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c writer.c -o writer.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-z,relro -o curl.so callbacks.o curl.o download.o escape.o fetch.o form.o getdate.o handle.o ieproxy.o init.o interrupt.o multi.o nslookup.o reflist.o split.o ssl.o typechecking.o utils.o version.o winidn.o writer.o -lcurl -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/00LOCK-curl/00new/curl/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (curl)

The downloaded source packages are in
        ‘/tmp/downloaded_packages’
root@e17b9ecae221:/# 

But as I said, binaries are much, much easier and on Debian 'testing' (generally) (almost always) as current as CRAN.

But you were lacking here had nothing to do with Rocker, but was basic unfamiliarity with Linux builds / Debian builds. And that is ok! We all started there at some point. I highly recommend to join the r-sig-debian list running off the usual Swiss mailserver. Lurk for a bit, ask there.

As this is not a Rocker issue I am closing this. Should I be overlooking or misunderstanding something please feel free to reopen. Thanks for your interest in Rocker.

vikram-rawat commented 3 years ago

I was using libpq-dev for Postgres. I forgot to remove it from reprex. I just want to install curl package in R to run my app.

this is the line that fails

RUN R -e "install.packages('curl', repos = c(CRAN = 'https://cloud.r-project.org'), type = 'source');"

I am unable to run this line even after using apt install r-cran-curl but apt install libcurl4-openssl-dev worked fine...

I just want to document it here for anybody who faces this issue again.

Thanks for replying so quickly and pointing me in the right direction. I assume Docker can't be used without basic know-how of Linux distros especially Debian in this case. So, I subscribed to the r-sig-debian mail group. Thanks again

eddelbuettel commented 3 years ago

You need to step back just a little:

apt install r-cran-curl install the binary package already built based on the CRAN source. Just how installing vim gets you a binary of vim. Because it installs a binary that is already made, it does not install the build-dependency.

Installing the package from CRAN does a source installation (by default) on Linux (unless you do RSPM, or BSPM, but they are not well known yet) and a source installation may need so-called build-dependencies and that (here) is the libcurl4-openssl-dev package (as the other, more basic, packages are already in via r-base-dev).

Hope this helps, and see you on r-sig-debian!