首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为闪亮的应用程序构建坞图时的包依赖问题

为闪亮的应用程序构建坞图时的包依赖问题
EN

Stack Overflow用户
提问于 2020-05-17 14:29:22
回答 1查看 1K关注 0票数 0

我正试图为我的闪亮的应用程序建立一个对接形象。我的对接映像是“成功”构建的,但不能在本地主机上启动。在图像构建过程中检查日志时,我看到了以下错误消息:

代码语言:javascript
复制
ERROR: dependency ‘sf’ is not available for package ‘leafpop’
* removing ‘/usr/local/lib/R/site-library/leafpop’
..........

1: In install.packages(c("remotes", "shiny", "shinythemes", "shinydashboard",  :>
  installation of package ‘units’ had non-zero exit status
2: In install.packages(c("remotes", "shiny", "shinythemes", "shinydashboard",  :
  installation of package ‘sf’ had non-zero exit status
3: In install.packages(c("remotes", "shiny", "shinythemes", "shinydashboard",  :
  installation of package ‘leafpop’ had non-zero exit status

看起来它有一些包依赖问题。看起来包leafpop依赖于sf。不确定包装units.

我的问题是:

  1. 如何修改我的Dockerfile以解决这个依赖问题?我想这也是一个一般性的问题.

  1. ,我等了很长一段时间,才完成了图像构建过程。我应该如何修改我的Dockerfile,以便当某些包安装失败时,它将停止构建过程?只是为了节省我的时间。

我的Dockerfile如下:

代码语言:javascript
复制
FROM rocker/shiny-verse

RUN apt-get update && apt-get install -y \
    sudo \
    gdebi-core \
    pandoc \
    pandoc-citeproc \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev

RUN wget --no-verbose https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/VERSION -O "version.txt" && \
    VERSION=$(cat version.txt)  && \
    wget --no-verbose "https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && \
    gdebi -n ss-latest.deb && \
    rm -f version.txt ss-latest.deb

RUN R -e "install.packages(c('remotes', 'shinythemes','shinydashboard','shinyWidgets','shinyjs', 'rlang','scales','DT','lubridate', 'plotly',  'leaflet', 'leafpop', 'visNetwork', 'wordcloud2', 'arules'), repos='http://cran.rstudio.com/')"
RUN R -e "remotes::install_github('nik01010/dashboardthemes')"


COPY shiny-server.conf  /etc/shiny-server/shiny-server.conf
COPY /app /srv/shiny-server/

EXPOSE 80

COPY shiny-server.sh /usr/bin/shiny-server.sh

CMD ["/usr/bin/shiny-server.sh"]
EN

回答 1

Stack Overflow用户

发布于 2020-05-17 17:20:46

错误日志通常会告诉您问题出在哪里。在units包中,找不到一个系统库,即libudunits2.so。错误消息甚至告诉您如何安装它。

代码语言:javascript
复制
--------------------------------------------------------------------------------
  Configuration failed because libudunits2.so was not found. Try installing:
    * deb: libudunits2-dev (Debian, Ubuntu, ...)
    * rpm: udunits2-devel (Fedora, EPEL, ...)
    * brew: udunits (OSX)
  If udunits2 is already installed in a non-standard location, use:
    --configure-args='--with-udunits2-lib=/usr/local/lib'
  if the library was not found, and/or:
    --configure-args='--with-udunits2-include=/usr/include/udunits2'
  if the header was not found, replacing paths with appropriate values.
  You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------

因为基本映像是基于debian映像的,所以使用apt包,即libudunits2-dev。使用apt-get安装该软件包修复了此错误。

sf有关的错误如下:

代码语言:javascript
复制
* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc
configure: CXX: g++ -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘sf’
* removing ‘/usr/local/lib/R/site-library/sf’
cat: leafpop.out: No such file or directory

The downloaded source packages are in
    ‘/tmp/RtmpmvJxnC/downloaded_packages’
Warning message:
In install.packages(c("remotes", "shinythemes", "shinydashboard",  :
  installation of one or more packages failed,
  probably ‘sf’, ‘leafpop’

这里的主要错误是找不到或不能执行gdal-config。在googling搜索之后,我们发现libgdal-dev包提供了gdal-config。用apt-get安装它可以解决这个问题。

今后,我建议通过尝试交互构建容器来进行调试。然后在Dockerfile中写入正确的命令。交互式调试比迭代修改Dockerfile容易。

关于您的第二个问题,install.packages接受一个Ncpus参数,它将并行编译包(如果包支持的话)。这可以显著减少您的构建时间。

代码语言:javascript
复制
install.packages(... Ncpus=6)  # for example
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61853440

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档