Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.09: # stat: can't read file system information for '%m': No such file or directory #8965

Closed
XVilka opened this issue Sep 23, 2019 · 13 comments · Fixed by #8979
Closed

4.09: # stat: can't read file system information for '%m': No such file or directory #8965

XVilka opened this issue Sep 23, 2019 · 13 comments · Fixed by #8979
Assignees

Comments

@XVilka
Copy link
Contributor

@XVilka XVilka commented Sep 23, 2019

I have the Alpine-based Dockerfile, with these lines:

FROM alpine:edge AS builder
RUN apk add --no-cache make m4 which patch sudo wget git pkgconfig \
	gcc g++ musl-dev linux-headers libffi libffi-dev pcre perl python3 \
	gmp-dev libressl-dev pcre-dev zlib-dev xz-dev \
	ocaml ocaml-compiler-libs ocaml-ocamldoc opam ocaml-findlib \
	unzip gmp xz

RUN chmod +s `which bwrap`

RUN addgroup -g 1000 -S user && adduser -u 1000 -D -S user -G user
RUN sed -i.bkp -e \
	's/%wheel\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%wheel ALL=NOPASSWD:ALL/g' \
	/etc/sudoers
COPY ocamlinit /home/user/.ocamlinit
USER user
WORKDIR /home/user

ENV OCAML_TOPLEVEL_PATH /home/user/.opam/default/lib/toplevel
RUN opam init --auto-setup --disable-sandboxing --yes && \
	# FIXME: Ugly hack
	ln -s /home/user/.opam/default/lib/toplevel /home/user/.opam/default/lib/topfind && \
	eval `opam env` && opam install --yes ocamlfind && \
	opam update --yes && export CHECK_IF_PREINSTALLED=false; \
	opam install --yes opam-devel

RUN eval `opam env` && \
	opam switch create 4.09.0 && \
	opam switch 4.09.0

And during the build it returns the following error

[ocaml-base-compiler.4.09.0] downloaded from cache at https://opam.ocaml.org/cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed base-bigarray.base
-> installed base-threads.base
-> installed base-unix.base
[ERROR] The compilation of ocaml-base-compiler failed at "/usr/bin/make -j7 world".

#=== ERROR while compiling ocaml-base-compiler.4.09.0 =========================#
# context              2.0.3 | linux/x86_64 |  | https://opam.ocaml.org#f335c4dc
# path                 ~/.opam/4.09.0/.opam-switch/build/ocaml-base-compiler.4.09.0
# command              /usr/bin/make -j7 world
# exit-code            2
# env-file             ~/.opam/log/ocaml-base-compiler-7-a00279.env
# output-file          ~/.opam/log/ocaml-base-compiler-7-a00279.out
### output ###
# [...]
# ./boot/ocamlrun ./boot/ocamlc -g -nostdlib -I boot -use-prims runtime/primitives -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66 -warn-error A -bin-annot -safe-string -strict-formats -I utils -I parsing -I typing -I bytecomp -I file_formats -I lambda -I middle_end -I middle_end/closure -I middle_end/flambda -I middle_end/flambda/base_types -I asmcomp -I asmcomp/debug -I dr[...]
# ./boot/ocamlrun ./boot/ocamlc -g -nostdlib -I boot -use-prims runtime/primitives -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66 -warn-error A -bin-annot -safe-string -strict-formats -I utils -I parsing -I typing -I bytecomp -I file_formats -I lambda -I middle_end -I middle_end/closure -I middle_end/flambda -I middle_end/flambda/base_types -I asmcomp -I asmcomp/debug -I dr[...]
# ./boot/ocamlrun ./boot/ocamlc -g -nostdlib -I boot -use-prims runtime/primitives -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66 -warn-error A -bin-annot -safe-string -strict-formats -I utils -I parsing -I typing -I bytecomp -I file_formats -I lambda -I middle_end -I middle_end/closure -I middle_end/flambda -I middle_end/flambda/base_types -I asmcomp -I asmcomp/debug -I dr[...]
# stat: can't read file system information for '%m': No such file or directory
# stat: can't read file system information for '%m': No such file or directory
# tools/check-parser-uptodate-or-warn.sh: line 48: arithmetic syntax error
# make[2]: *** [Makefile:1079: parsing/parser.ml] Error 2
# make[2]: *** Waiting for unfinished jobs....
# make[2]: Leaving directory '/home/user/.opam/4.09.0/.opam-switch/build/ocaml-base-compiler.4.09.0'
# make[1]: *** [Makefile:355: coreall] Error 2
# make[1]: Leaving directory '/home/user/.opam/4.09.0/.opam-switch/build/ocaml-base-compiler.4.09.0'
# make: *** [Makefile:463: world] Error 2

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build ocaml-base-compiler 4.09.0
+- 
+- The following changes have been performed (the rest was aborted)
| - install base-bigarray base
| - install base-threads  base
| - install base-unix     base
+- 

<><> ocaml-base-compiler.4.09.0 troubleshooting <><><><><><><><><><><><><><><><>
=> A failure in the middle of the build may be caused by build parallelism
      (enabled by default).
      Please file a bug report at https://github.com/ocaml/ocaml/issues
# Run eval $(opam env) to update the current shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] n
The command '/bin/sh -c eval `opam env` &&      opam switch create 4.09.0 &&    opam switch 4.09.0' returned a non-zero code: 31
@Armael

This comment has been minimized.

Copy link
Member

@Armael Armael commented Sep 23, 2019

@gasche

This comment has been minimized.

Copy link
Member

@gasche gasche commented Sep 24, 2019

Sounds like a problem in a script I wrote, tools/check-parser-uptodate-or-warn.sh (current version). The relevant logic is as follows:

stat . 2>/dev/null 1>/dev/null
if test $? != 0
then MTIME=""
elif test -n "$(stat --version 2>/dev/null | grep coreutils)"
then MTIME="stat --format %Y"
else MTIME="stat -f %m"
fi

mtime() {
  if test -z "$MTIME"
  then echo 0
  else $MTIME "$1"
  fi
}

@XVilka, could you try to find out what's the right way to invoke stat to get the modification time of a file on your system? Ideas for how to fix the script above to keep working would be extra welcome.

@gasche

This comment has been minimized.

Copy link
Member

@gasche gasche commented Sep 24, 2019

P.S.: this page seems to indicate that Alpine's /bin/stat is the GNU coreutils one, which suggests that one should indeed use stat --format %Y. But then, why didn't my oh-so-robust test stat --version | grep coreutils detect that it was the coreutils stat? What does stat --version return on Alpine?

@gasche gasche self-assigned this Sep 24, 2019
@XVilka

This comment has been minimized.

Copy link
Contributor Author

@XVilka XVilka commented Sep 25, 2019

@gasche seems it uses busybox one? And it indeed doesn't have %m format option:

docker run -it --rm alpine:edge /bin/ash                                                                                                                                                                                     16:57:23 
zsh: correct '/bin/ash' to '/bin/as' [nyae]? n
Unable to find image 'alpine:edge' locally
edge: Pulling from library/alpine
01fa3b4a8bd4: Pull complete 
Digest: sha256:484dfd8f6ffc7237d4d91cb107dad73f4594c33eacfd0fe77c284e36bad9303d
Status: Downloaded newer image for alpine:edge
/ # stat --version
stat: unrecognized option: version
BusyBox v1.31.0 (2019-07-24 08:12:26 UTC) multi-call binary.

Usage: stat [OPTIONS] FILE...

Display file (default) or filesystem status

        -c FMT  Use the specified format
        -f      Display filesystem status
        -L      Follow links
        -t      Terse display

FMT sequences for files:
 %a     Access rights in octal
 %A     Access rights in human readable form
 %b     Number of blocks allocated (see %B)
 %B     Size in bytes of each block reported by %b
 %d     Device number in decimal
 %D     Device number in hex
 %f     Raw mode in hex
 %F     File type
 %g     Group ID
 %G     Group name
 %h     Number of hard links
 %i     Inode number
 %n     File name
 %N     File name, with -> TARGET if symlink
 %o     I/O block size
 %s     Total size in bytes
 %t     Major device type in hex
 %T     Minor device type in hex
 %u     User ID
 %U     User name
 %x     Time of last access
 %X     Time of last access as seconds since Epoch
 %y     Time of last modification
 %Y     Time of last modification as seconds since Epoch
 %z     Time of last change
 %Z     Time of last change as seconds since Epoch

FMT sequences for file systems:
 %a     Free blocks available to non-superuser
 %b     Total data blocks
 %c     Total file nodes
 %d     Free file nodes
 %f     Free blocks
 %i     File System ID in hex
 %l     Maximum length of filenames
 %n     File name
 %s     Block size (for faster transfer)
 %S     Fundamental block size (for block counts)
 %t     Type in hex
 %T     Type in human readable form
/ # 

If I run it with /bin/sh instead, it still calls the busybox stat tool.

@gasche

This comment has been minimized.

Copy link
Member

@gasche gasche commented Sep 25, 2019

So it looks like busybox's stat is detected with stat 2>&1 | grep busybox, and that the right command to use in this case is stat -c %Y -- which I could also use for the GNU tool.

@Octachron

This comment has been minimized.

Copy link
Contributor

@Octachron Octachron commented Sep 25, 2019

How hard would it be to not run this test on released version? Testing if the boostrapped parser is up to date feels more like a development concern than a release one.

@gasche

This comment has been minimized.

Copy link
Member

@gasche gasche commented Sep 25, 2019

In any case I must fix the Makefile to ensure that its failure does not prevent the build.

I can indeed check the VERSION file and try to disable any logic if we don't see +dev?

@Octachron

This comment has been minimized.

Copy link
Contributor

@Octachron Octachron commented Sep 25, 2019

Disabling the test on VERSION not containing "+dev" sounds like a good idea to me.

gasche added a commit to gasche/ocaml that referenced this issue Sep 25, 2019
gasche added a commit to gasche/ocaml that referenced this issue Sep 25, 2019
@gasche

This comment has been minimized.

Copy link
Member

@gasche gasche commented Sep 25, 2019

I proposed a fix in #8979.

@shindere

This comment has been minimized.

Copy link
Contributor

@shindere shindere commented Sep 25, 2019

@shindere

This comment has been minimized.

Copy link
Contributor

@shindere shindere commented Sep 25, 2019

@gasche

This comment has been minimized.

Copy link
Member

@gasche gasche commented Sep 25, 2019

The script that provoked a build failure here is a heuristic to emit a warning in certain cases. It should never break the build. I prefer to minimize the risk that it breaks, and it seems that disabling the tests on non-dev build is a safe way to minimize the risk (just like we do not enable -Werror on non-development builds).

@shindere

This comment has been minimized.

Copy link
Contributor

@shindere shindere commented Sep 25, 2019

gasche added a commit to gasche/ocaml that referenced this issue Sep 26, 2019
@gasche gasche closed this in #8979 Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.