【问题标题】:Error installing watchman into a Python docker container在 Python docker 容器中安装 watchman 时出错
【发布时间】:2021-03-07 05:58:02
【问题描述】:

如何将 watchman 安装到我的 python docker 容器中?我已经尝试按照守望者documentation 中的描述从源代码安装它,但没有运气。这是我的Dockerfile

FROM python:3.9

# install watchman
RUN git clone https://github.com/facebook/watchman.git -b v4.9.0 --depth 1 && \
  cd watchman && \
  ./autogen.sh && \
  ./configure && \
  make && \
  make install

这是我尝试构建映像时的错误:

$ docker image build --tag pythonwatchman .
...
#5 141.5   CXX      root/watchman-warnerr.o
#5 143.0   CXX      root/watchman-watchlist.o
#5 144.9   CXX      scm/watchman-Mercurial.o
#5 145.6 scm/Mercurial.cpp: In constructor ‘watchman::Mercurial::infoCache::infoCache(std::__cxx11::string)’:
#5 145.6 scm/Mercurial.cpp:16:40: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct watchman::FileInformation’; use assignment or value-initialization instead [-Werror=class-memaccess]
#5 145.6    memset(&dirstate, 0, sizeof(dirstate));
#5 145.6                                         ^
#5 145.6 In file included from scm/Mercurial.h:10,
#5 145.6                  from scm/Mercurial.cpp:3:
#5 145.6 ./FileInformation.h:18:8: note: ‘struct watchman::FileInformation’ declared here
#5 145.6  struct FileInformation {
#5 145.6         ^~~~~~~~~~~~~~~
#5 146.8 cc1plus: all warnings being treated as errors
#5 146.8 make[1]: *** [Makefile:4446: scm/watchman-Mercurial.o] Error 1
#5 146.8 make[1]: Leaving directory '/watchman'
#5 146.8 make: *** [Makefile:1264: all] Error 2

有没有办法解决这个问题?或者有没有更好的方法将 watchman 安装到这个容器中?

【问题讨论】:

    标签: python docker watchman


    【解决方案1】:

    或者有没有更好的方法将 watchman 安装到这个容器中?

    是的,你可以直接将他们的预编译二进制安装到容器中,不需要从源代码构建,参见this

    接下来是一个完整的解决方案,仅供参考。

    Dockerfile:

    FROM python:3.9
    
    ARG WM_VERSION=v2021.03.01.00
    
    # install watchman
    RUN wget https://github.com/facebook/watchman/releases/download/$WM_VERSION/watchman-$WM_VERSION-linux.zip && \
    unzip watchman-$WM_VERSION-linux.zip && \
    cd watchman-$WM_VERSION-linux && \
    mkdir -p /usr/local/{bin,lib} /usr/local/var/run/watchman && \
    cp bin/* /usr/local/bin && \
    cp lib/* /usr/local/lib && \
    chmod 755 /usr/local/bin/watchman && \
    chmod 2777 /usr/local/var/run/watchman && \
    cd .. && \
    rm -fr watchman-$WM_VERSION-linux.zip watchman-$WM_VERSION-linux
    

    验证:

    $ docker build -t abc:1 .
    $ docker run --rm -it abc:1 watchman --version
    20210222.215625.0
    

    你可以看到我们现在已经可以运行watchman command了。

    顺便说一句,所有预定义的二进制文件都可以在github 中找到。

    【讨论】:

    • 只需要一个cd ..,然后再删除守望者文件(最后一行)即可使其正常工作。否则完美运行。
    • @JohnnyMetz 是的,你完全正确,更新了。
    • 不得不每隔几个月手动更新版本很烦人。有没有办法下载最新的 linux 二进制文件?
    • 我在这里打开了一个关于下载最新 linux 二进制文件的问题:github.com/facebook/watchman/issues/982
    猜你喜欢
    • 1970-01-01
    • 2021-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多