eradman/entr

fatal error: sys/sysctl.h: No such file or directory

siherrmann opened this issue · 3 comments

Hey, I'm working with the entr package in docker images. I'm very happy to have easy hot reload in my golang services. Since today the docker containers running entr won't start. The error I get is:

> [user 8/9] RUN git clone https://github.com/eradman/entr && cd entr/ && ./configure && make test && make install:
0.116 Cloning into 'entr'...
0.749 + cp Makefile.linux Makefile
0.753 cc  -D_GNU_SOURCE -D_LINUX_PORT -Imissing -DRELEASE=\"5.5\"  missing/strlcpy.c missing/kqueue_inotify.c entr.c -o entr
0.801 entr.c:21:10: fatal error: sys/sysctl.h: No such file or directory
0.801    21 | #include <sys/sysctl.h>
0.801       |          ^~~~~~~~~~~~~~
0.801 compilation terminated.
0.802 make: *** [Makefile.bsd:15: entr] Error 1
------
failed to solve: process "/bin/sh -c git clone https://github.com/eradman/entr && cd entr/ && ./configure && make test && make install" did not complete successfully: exit code: 2

My dockerfile looks like that:

FROM golang:alpine
WORKDIR /

# Adding my own folders with helper code.
ADD ...

# Update module env variable.
RUN go env -w GO111MODULE=auto

# Get necessary packages for entr.
RUN apk add g++ && apk add make && apk add git

# File watcher for running tests on watch mode
RUN git clone https://github.com/eradman/entr && cd entr/ && ./configure && make test && make install

# Fix file watcher on Mac (see: https://github.com/eradman/entr/issues/3)
ENV ENTR_INOTIFY_WORKAROUND 1 

# # If you want to try to run your program without hot reload:
# RUN go build -o .
# CMD ls *.go | entr -n -r go build . && go run .

EXPOSE myport

My docker version is Docker version 24.0.6, build ed223bc.
My docker-compose version is Docker Compose version v2.22.0-desktop.2.
I'm running the docker containers in a big docker compose file with all services in it.
Running a single Dockerfile doesn't help (so probably not a docker-compose issue).

I also tried with older alpine versions (so for example golang:alpine3.16) as that is the only variable that has probably changed (as far as I can imagine). What could be the problem and is there a known way to solve it?

Thanks for all the good work.

Ok, I saw that you added #include <sys/sysctl.h> in your last commit. I went back to an older commit and now it works again. I'm not very familiar with C/C++, but ist there a way to make this import/include conditional?

Thanks for catching this! Fixed in commit fdc5500

Thanks for the fast fix, appreciate it. I tried it and it works perfectly.