Skip to content

jbuilder subst -n <name> is sometimes not properly rooted #954

@samoht

Description

@samoht

To reproduce:

  • install opam 2.0rc3, enable sandboxing
  • clone ocaml-cohttp: https://github.com/mirage/ocaml-cohttp
  • in that directory, create a local switch: opam switch create . 4.06.1
  • then opam install cohttp. You will get:
#=== ERROR while compiling cohttp.1.1.0 =======================================#
# context     2.0.0~rc3 | macos/x86_64 | ocaml-base-compiler.4.06.1 | pinned(git+file:///Users/thomas/git/ocaml-cohttp#master#2de6f277)
# path        ~/git/ocaml-cohttp/_opam/.opam-switch/build/cohttp.1.1.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build jbuilder subst -n cohttp
# exit-code   1
# env-file    ~/.opam/log/cohttp-63694-6cc03f.env
# output-file ~/.opam/log/cohttp-63694-6cc03f.out
### output ###
# Entering directory '/Users/thomas/git/ocaml-cohttp'
# Error: exception Sys_error("cohttp-async.opam: Operation not permitted")
# Backtrace:
# Raised by primitive operation at file "pervasives.ml", line 315, characters 29-55
# Called from file "src/stdune/io.ml", line 16, characters 15-36
# Called from file "list.ml", line 100, characters 12-15
# Called from file "src/watermarks.ml", line 226, characters 2-100
# Called from file "src/fiber/fiber.ml", line 359, characters 6-13

You can reproduce that by going into the local switch and running the command again:

$ cd _opam/.opam-switch/build/cohttp.1.1.0
$ ~/.opam/opam-init/hooks/sandbox.sh build jbuilder subst -n cohttp
Entering directory '/Users/thomas/git/ocaml-cohttp'
Error: exception Sys_error("cohttp-async.opam: Operation not permitted")
Backtrace:
Raised by primitive operation at file "pervasives.ml", line 315, characters 29-55
Called from file "src/stdune/io.ml", line 16, characters 15-36
Called from file "list.ml", line 100, characters 12-15
Called from file "src/watermarks.ml", line 226, characters 2-100
Called from file "src/fiber/fiber.ml", line 359, characters 6-13

jbuilder tries to modify the source directory, not the temporary checkout!

And this works:

$ ~/.opam/opam-init/hooks/sandbox.sh build jbuilder subst -n cohttp --root .

/cc @rjbou

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions