infer icon indicating copy to clipboard operation
infer copied to clipboard

Fail to build infer (Linux)

Open wang-weishi opened this issue 3 years ago • 3 comments

Hi, I am trying to build infer on the google cloud platform, and I came across an error during building the infer. Below are some error logs:

  • Once run ./build-infer.sh java ocaml --version The OCaml toplevel, version 4.08.1 opam --version 2.0.5
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
∗ installed ocaml-option-flambda.1
[ERROR] The compilation of ocaml-variants failed at "/root/.opam/opam-init/hooks/sandbox.sh build ./configure --prefix=/root/.opam/4.12.0+flambda -C --enable-flambda".

#=== ERROR while compiling ocaml-variants.4.12.0+options ======================#
# context     2.0.5 | linux/x86_64 | ocaml-option-flambda.1 | https://opam.ocaml.org#93ee8809
# path        ~/.opam/4.12.0+flambda/.opam-switch/build/ocaml-variants.4.12.0+options
# command     ~/.opam/opam-init/hooks/sandbox.sh build ./configure --prefix=/root/.opam/4.12.0+flambda -C --enable-flambda
# exit-code   1
# env-file    ~/.opam/log/ocaml-variants-9827-e7966f.env
# output-file ~/.opam/log/ocaml-variants-9827-e7966f.out
### output ###
# bwrap: Creating new namespace failed: Operation not permitted



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-variants 4.12.0+options
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray        base
│ ∗ install base-threads         base
│ ∗ install base-unix            base
│ ∗ install ocaml-option-flambda 1
└─ 

<><> ocaml-variants.4.12.0+options 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/opam-repository/issues
=> You can try installing again including --jobs=1
      to force a sequential build instead.
# Run eval $(opam env) to update the current shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y

*** ERROR: `opam_switch_create_if_needed 4.12.0+flambda --package=ocaml-variants.4.12.0+options,ocaml-option-flambda` failed

Do I need to adjust the: INFER_OPAM_DEFAULT_SWITCH="4.12.0+flambda" INFER_OPAM_DEFAULT_SWITCH_OPTIONS="--package=ocaml-variants.4.12.0+options,ocaml-option-flambda"

and how to correct them?

Thank you so much for your help

wang-weishi avatar Nov 24 '21 20:11 wang-weishi

[edited your post to add formatting]

Hi @wang-weishi, it looks like an issue with bwrap, the sandboxing utility that opam uses. I don't know how to fix the issue itself but you shouldn't need the sandboxing since your job is already running in a container, so you could adjust the opam options to include --disable-sandboxing. I think that only matters in the opam init command here: https://github.com/facebook/infer/blob/733696724e1c79bb15de5170807507e837b3b978/build-infer.sh#L138

jvillard avatar Nov 25 '21 10:11 jvillard

@jvillard Thanks for the suggestions, I have already disabled sandboxing, and the same error happens as shown by @thyecust. If anyone knows how to fix this issue, could you please kindly leave some hints? Thanks in advance!

wang-weishi avatar Nov 29 '21 06:11 wang-weishi

you can try running ./build-infer.sh java --no-opam-lock.

thyecust avatar Jan 19 '22 18:01 thyecust