Hi, I have a permission problem with flock when trying to install or update to coq-8.15 or 8.14.1 (did no try other versions).
Any clue?
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of coq failed at "/home/courtieu/.opam/opam-init/hooks/sandbox.sh build make COQ_USE_DUNE= -j15".
#=== ERROR while compiling coq.8.14.1 =========================================#
# context 2.0.10 | linux/x86_64 | ocaml-base-compiler.4.12.0 | https://opam.ocaml.org#10a48cb9
# path ~/.opam/full-coq/.opam-switch/build/coq.8.14.1
# command ~/.opam/opam-init/hooks/sandbox.sh build make COQ_USE_DUNE= -j15
# exit-code 2
# env-file ~/.opam/log/coq-800031-06fa5f.env
# output-file ~/.opam/log/coq-800031-06fa5f.out
### output ###
# [...]
# make --warn-undefined-variable --no-builtin-rules -f Makefile.build
# make[1]: Entering directory '/home/courtieu/.opam/full-coq/.opam-switch/build/coq.8.14.1'
# MKDIR BUILD_OUT
# DUNE _build/install/default/bin/coqdep
# make[1]: flock: Permission denied
More info about your system would be useful... What is your host operating system? Which filesystems are you using? Does disabling opam sandboxing make a difference? Do you have any configuration in ~/.config/dune/config
?
AFAIK, you're testing the combination of (1) dune (which is used in parts of the Coq build, even with COQ_USE_DUNE=
) (2) opam sandboxing (3) the flock
helper for file locking (but I don't know why Coq's build system builds and uses that program)
dune can't be run in parallel so we serialize calls with flock
Wasn't this replaced with something else, because flock is not available on Mac? I thought dune (or whoever calls flock) now uses an OCaml bases solution (flock is available as C function on macOS).
Possibly updating dune or opam helps.
I've seen Coq include its own flock
binary
Search for "flock" in the Coq devs zulip stream.
we compile our own flock only if there isn't one in PATH
I don't have flock - and I have macOS and Coq Platform in path and building Coq 8.14.1 and 8.15.0 works (via opam).
@Pierre Courtieu what does shell command -v flock
say?
Ah no:
coq-platform-main$ find ~/.opam -name flock
/Users/msoegtrop/.opam/__coq-platform.2022.01.0~dev/.opam-switch/sources/coq.dev/tools/flock
/Users/msoegtrop/.opam/__coq-platform.2022.01.0~dev/.opam-switch/sources/coqide.dev/tools/flock
/Users/msoegtrop/.opam/__coq-platform.2022.01.0~8.15~beta1/.opam-switch/sources/coqide.8.15.0/tools/flock
/Users/msoegtrop/.opam/__coq-platform.2022.01.0~8.15~beta1/.opam-switch/sources/coq.8.15.0/tools/flock
So 8.14 doesn't have one. But it still builds for me by some magic.
Well and still I don't have binaries ...
it's called coq_flock.exe and isn't installed, just used for building
@Pierre Courtieu : as I said, I don't have a flock binary in path - still building works for me.
I don't think flock: permission denied
is a coq_flock error, it seems like a normal flock binary
to me "flock: permission denied" more looks like there is a file flock which bash tries to execute but it is not executable.
test$ echo bla > flock
test$ ./flock
-bash: ./flock: Permission denied
P.S.: zsh gives a permission denied
with lower case p - bash with upper case P.
but that has the ./
prefix
PATH lookups only try executables so that wouldn't happen
@Pierre Courtieu : possibly you have some relics lying around from trying to work around this a few months back ...
Thanks for the answers. I will try from a clean config. FTR I am under debian and I don't think I did anything with opam config. I ll let you know. Thanks again.
Nothing changed. I just erased the .opam directory. Then reinstalled from scratch:
opam init
eval $(opam env)
echo $PATH
==> /home/courtieu/.opam/default/bin:home/courtieu/.sdkman/candidates/gradle/current/bin:.:/usr/local/jdk1.8.0_171/bin:/usr/local/netbeans-8.2/bin:/home/courtieu/coq/actual/bin:/home/courtieu/coq/actual/tools:/home/courtieu/src/why3-inst/bin:/home/courtieu/.bin:/home/courtieu/config/scripts:/home/courtieu/.local/bin:/home/courtieu/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin:/sbin:/usr/sbin::/home/courtieu/.local/bin)
opam install coq
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed conf-findutils.1
∗ installed conf-gmp.4
∗ installed ocamlfind.1.9.3
∗ installed zarith.1.12
∗ installed dune.2.9.2
[ERROR] The compilation of coq failed at "/home/courtieu/.opam/opam-init/hooks/sandbox.sh build make COQ_USE_DUNE= -j15".
#=== ERROR while compiling coq.8.15.0 =========================================#
# context 2.0.10 | linux/x86_64 | ocaml-base-compiler.4.13.1 | https://opam.ocaml.org#b3f8647a
# path ~/.opam/default/.opam-switch/build/coq.8.15.0
# command ~/.opam/opam-init/hooks/sandbox.sh build make COQ_USE_DUNE= -j15
# exit-code 2
# env-file ~/.opam/log/coq-871287-abfa5b.env
# output-file ~/.opam/log/coq-871287-abfa5b.out
### output ###
# [...]
# make --warn-undefined-variable --no-builtin-rules -f Makefile.build
# make[1]: Entering directory '/home/courtieu/.opam/default/.opam-switch/build/coq.8.15.0'
# MKDIR BUILD_OUT
# DUNE _build/install/default/bin/coqdep
# make[1]: flock: Permission denied
# DUNE sources
Interestingly when I clone coq master and try "configure -profile devel ; make" it fails the same way. When I do dune build
it does not fail.
If you run flock foo echo hello
what happens?
(foo is an arbitrary file name)
if that works, please also test ~/.opam/opam-init/hooks/sandbox.sh build flock foo echo hello
to see if the sandbox makes a difference
Gaëtan Gilbert said:
If you run
flock foo echo hello
what happens?
gives
hello
and
~/.opam/opam-init/hooks/sandbox.sh build flock foo echo hello
prints nothing.
but again when I do make
in coq sources I get the same error.
In coq sources, make -f Makefile.dune world
succeeds,
but (on fresh sources) $ ./configure -profile devel
followed by make
fails with the same flock error. I don't think this ha something to do with sandbox.sh but with the legacy makefile build.
Which build system does opam use for coq?
From the top directory of the Coq sources, you can try flock .dune.lock echo foo
.
Guillaume Melquiond said:
From the top directory of the Coq sources, you can try
flock .dune.lock echo foo
.
Hi, it shows foo
.
@Pierre Courtieu COQ_USE_DUNE=
means opam's package uses dune only where unavoidable (IIRC, for the OCaml code).
what about flock .dune.lock dune --version
?
the .opam
packages in Coq itself already use dune fully
$ flock .dune.lock dune --version
2.9.2
what about make VERBOSE=1
after configure?
Maybe we should switch to another channel? Sould I fill a bug?
here is fine until we've got something reproducible IMO
$ ./configure -profile devel
You have OCaml 4.13.1. Good!
You have OCamlfind 1.9.3. Good!
You have native-code compilation. Good!
You have the Zarith library 1.12 installed. Good!
...
$ make VERBOSE=1
make --warn-undefined-variable --no-builtin-rules -f Makefile.build
make[1]: Entering directory '/home/courtieu/coq/master'
flock .dune.lock dune build --display=quiet --profile=dev _build/install/default/bin/coqdep
make[1]: flock: Permission denied
flock .dune.lock dune build --display=quiet --profile=dev _build/install/default/bin/coqc
make[1]: flock: Permission denied
make[1]: *** [Makefile.common:131: _build/install/default/bin/coqc] Error 127
make[1]: Leaving directory '/home/courtieu/coq/master'
make: *** [Makefile.make:122: submake] Error 2
doing by hand flock .dune.lock dune build --display=quiet --profile=dev _build/install/default/bin/coqdep
does not fail.
really strange. I am currently stuck out of opam :-(
Since this problem is specific to flock
, using opam install ./coq-core.opam
should build Coq bypassing this problem
ha. That we unstuck me. What does it do exactly?
or even opam install .
to install all the packages, apparently (I'm not sure that's the perfect way of doing this).
well you said that pure dune builds (make -f Makefile.dune world
) succeed, and those opam packages use the pure dune builds
OK. But then installing coq packages depending on coq won't work.
ho yes it will with opam install .
there's also a coq.opam
package; they claim to have version dev
, but even that can be changed
(at least by editing the version
field; I forget the syntax for doing it on the cmd line)
OK this seems to work a bit. I still don't understand the initial problem. I will investigate a bit more.
FTR one year later, I understood this flock problem...
If I have in my PATH a directory containing <sources of coq>/tools
, then it messes with opam compilation because then flock
is actually seen as the directory <sources of coq>/tools/flock
instead of a binary.
This is perfectly expectable but was hard to pinpoint from the error (flock permission denied), because which flock
gives the path of the correct executable (citing its doc: "The command works by locating the executable file matching the given command")...
Don't know if this is worth a bug report for opam, or coq: I guess flock executable should be detected consistently with the system.
Wait, searching for a binary finds a folder?
It seems definitely worth a bug report
I'd have expected executable search to be implemented once and for all in OCaml, making this an OCaml bug? If not, why not?
Or mayb my config is definitely broken :-)
Paolo Giarrusso said:
Wait, searching for a binary finds a folder?
As dumb as it might seem, this behavior complies with the posix standard. You can try it for yourself with a command like:
$ dash -c 'PATH=/usr bin'
dash: 1: bin: Permission denied
(More evolved shells such as Bash exclude directories from their search for directory entries with the executable bit set, which is a much saner behavior.)
I still don’t know if this is a bug and (if yes) of what it would be a bug :-). opam, dune, coq, bash?
:man_facepalming: oh I have a guess, sorry. Can you run ls -l /bin/sh
, confirm that it points to dash (maybe indirectly?), then reproduce @Guillaume Melquiond 's example? My advice then is to make /bib/sh point to bash or the like
The error was thrown when make executed flock. Make's spec demands that, by default, make runs commands via /bin/sh. Debian decided to make that point to dash. And dash... Dunno, made what seems here the unfortunate choice to follow the standard instead of do something smarter?
are we sure it's a choice and not just a bug?
I'd consider just reporting a bug to dash
: https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html on execvp
seems
terribly vague here, but Debian's dash seems to not use execvp
anyway https://salsa.debian.org/debian/dash/-/blob/debian/unstable/src/exec.c.
Last updated: Oct 13 2024 at 01:02 UTC