digitalocean / prometheus-client-c

A Prometheus Client in C
Other
158 stars 78 forks source link

Build fails under Arch Linux (undefined: io.Discard) #78

Open pensnarik opened 1 year ago

pensnarik commented 1 year ago

I got the following error when trying to build the library:

$ make
...
Step 1/4 : FROM ubuntu:18.04
...
Processing triggers for mime-support (3.60ubuntu1) ...
+ rm -f /usr/bin/gcc
+ ln -s /usr/bin/gcc-10 /usr/bin/gcc
+ curl -sL https://github.com/Kitware/CMake/releases/download/v3.14.5/cmake-3.14.5-Linux-x86_64.tar.gz
+ tar xzf - -C /opt
+ cp /opt/cmake-3.14.5-Linux-x86_64/bin/ccmake /opt/cmake-3.14.5-Linux-x86_64/bin/cmake /opt/cmake-3.14.5-Linux-x86_64/bin/cmake-gui /opt/cmake-3.14.5-Linux-x86_64/bin/cpack /opt/cmake-3.14.5-Linux-x86_64/bin/ctest /usr/local/bin/
+ cp -R /opt/cmake-3.14.5-Linux-x86_64/share/cmake-3.14 /usr/local/share/
+ curl -sL https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz
+ tar xzf - -C /usr/local
+ mkdir -p /gopath/{src,bin}
+ printf export GOPATH=/gopath\nexport PATH=$PATH:/usr/local/go/bin:/gopath/bin\n
+ printf #!/usr/bin/env bash\nsource /root/.bash_profile\nexec /bin/bash $@\n
+ chmod +x /entrypoint
+ GOPATH=/gopath /usr/local/go/bin/go get github.com/prometheus/prom2json
# github.com/prometheus/common/expfmt
gopath/src/github.com/prometheus/common/expfmt/decode.go:89:34: cannot use v (type *io_prometheus_client.MetricFamily) as type protoreflect.ProtoMessage in argument to pbutil.ReadDelimited:
    *io_prometheus_client.MetricFamily does not implement protoreflect.ProtoMessage (missing ProtoReflect method)
gopath/src/github.com/prometheus/common/expfmt/encode.go:120:36: cannot use v (type *io_prometheus_client.MetricFamily) as type protoreflect.ProtoMessage in argument to pbutil.WriteDelimited:
    *io_prometheus_client.MetricFamily does not implement protoreflect.ProtoMessage (missing ProtoReflect method)
gopath/src/github.com/prometheus/common/expfmt/text_create.go:46:27: undefined: io.Discard
The command '/bin/sh -c set -x &&     apt-get update &&     apt-get install -y apt-utils software-properties-common clang-format &&     add-apt-repository ppa:ubuntu-toolchain-r/test &&     apt-get update -y &&     apt-get install -y curl tar build-essential git pkg-config gdb valgrind gcc-10 libmicrohttpd-dev doxygen graphviz &&     rm -f /usr/bin/gcc &&     ln -s /usr/bin/gcc-10 /usr/bin/gcc &&     curl -sL https://github.com/Kitware/CMake/releases/download/v3.14.5/cmake-3.14.5-Linux-x86_64.tar.gz | tar xzf - -C /opt &&     cp /opt/cmake-3.14.5-Linux-x86_64/bin/* /usr/local/bin/ &&     cp -R /opt/cmake-3.14.5-Linux-x86_64/share/cmake-3.14 /usr/local/share/ &&     curl -sL https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz 2> /dev/null | tar xzf - -C /usr/local &&     mkdir -p /gopath/{src,bin} &&     printf 'export GOPATH=/gopath\nexport PATH=$PATH:/usr/local/go/bin:/gopath/bin\n' > /root/.bash_profile &&     printf '#!/usr/bin/env bash\nsource /root/.bash_profile\nexec /bin/bash $@\n' > /entrypoint &&     chmod +x /entrypoint &&     GOPATH=/gopath /usr/local/go/bin/go get github.com/prometheus/prom2json &&     GOPATH=/gopath /usr/local/go/bin/go install github.com/prometheus/prom2json/cmd/prom2json &&     GOPATH=/gopath /usr/local/go/bin/go get github.com/git-chglog/git-chglog &&     GOPATH=/gopath /usr/local/go/bin/go install github.com/git-chglog/git-chglog/cmd/git-chglog &&     rm -rf /var/lib/apt/lists/*' returned a non-zero code: 2
make[1]: *** [Makefile:2: docker] Error 2
make[1]: Leaving directory '/home/mutex/dist/src/odyssey/include/prometheus-client-c/docker'
ERROR: Docker Build Failure
make: *** [Makefile:26: clean] Error 2

I'm building from master branch, commit hash = c57034d196582d99267d027abb52a05a55dc07f6. Myabe go version iw wrong or am I missed something?

pensnarik commented 1 year ago

That's probably related to https://github.com/prometheus/common/issues/381

pensnarik commented 1 year ago

UPD. I finally managed to build it by changing golang version from 1.13 to 1.17 and adding @latest to go install command for prom2json and git-chglog but now one of the tests fails:

test 9
      Start  9: prom_metric_formatter_test

9: Test command: /code/prom/build/prom_metric_formatter_test
9: Test timeout computed to be: 10000000
9: /code/prom/test/prom_metric_formatter_test.c:132:test_prom_metric_formatter_load_l_value:PASS
9: /code/prom/test/prom_metric_formatter_test.c:133:test_prom_metric_formatter_load_sample:PASS
9: /code/prom/test/prom_metric_formatter_test.c:134:test_prom_metric_formatter_load_metric:PASS
9: /code/prom/test/prom_metric_formatter_test.c:112:test_prom_metric_formatter_load_metrics:FAIL: Expected Non-NULL
9: 
9: -----------------------
9: 4 Tests 1 Failures 0 Ignored 
9: FAIL
 9/14 Test  #9: prom_metric_formatter_test .......***Failed    0.00 sec