Creating an opam local switch with a space in the current directory fails

I tried running the command opam switch create . 4.07.1 in a directory test-space, and it failed:

#=== ERROR while installing ocaml-base-compiler.4.07.1 ========================#
# context     2.0.7 | linux/x86_64 |  | https://opam.ocaml.org#8bc23dc0
# path        ~/tmp/test space/_opam/.opam-switch/build/ocaml-base-compiler.4.07.1
# command     ~/.opam/opam-init/hooks/sandbox.sh install make install
# exit-code   2
# env-file    ~/.opam/log/ocaml-base-compiler-34399-6cc03f.env
# output-file ~/.opam/log/ocaml-base-compiler-34399-6cc03f.out
### output ###
# [...]
# make[1]: Entering directory '/home/schmitta/tmp/test space/_opam/.opam-switch/build/ocaml-base-compiler.4.07.1/stdlib'
# rm -f "/home/schmitta/tmp/test space/_opam/lib/ocaml/seq.cmo" "/home/schmitta/tmp/test space/_opam/lib/ocaml/char.cmo" "/home/schmitta/tmp/test space/_opam/lib/ocaml/uchar.cmo" "/home/schmitta/tmp/test space/_opam/lib/ocaml/sys.cmo" "/home/schmitta/tmp/test space/_opam/lib/ocaml/list.cmo" "/home/schmitta/tmp/test space/_opam/lib/ocaml/bytes.cmo" "/home/schmitta/tmp/test space/_opam/lib/ocaml/[...]
# rm -f "/home/schmitta/tmp/test space/_opam/lib/ocaml/pervasives.*" "/home/schmitta/tmp/test space/_opam/lib/ocaml/bigarray.*"
# install -m u=rw,g=rw,o=r \
#   stdlib.cma std_exit.cmo *.cmi *.cmt *.cmti *.mli *.ml camlheader_ur \
#   "/home/schmitta/tmp/test space/_opam/lib/ocaml"
# install -m u=rw,g=rw,o=r target_camlheader "/home/schmitta/tmp/test space/_opam/lib/ocaml/camlheader"
# install -m u=rw,g=rw,o=r target_camlheaderd /home/schmitta/tmp/test space/_opam/lib/ocaml
# install: target 'space/_opam/lib/ocaml' is not a directory
# make[1]: *** [Makefile:104: install] Error 1
# make[1]: Leaving directory '/home/schmitta/tmp/test space/_opam/.opam-switch/build/ocaml-base-compiler.4.07.1/stdlib'
# make: *** [Makefile:608: install] Error 2

Is this a known bug, or should I report it?

It has been fixed in 4.08, if you need an older version you will need to patch it yourself (the commit with the fix can be found here).
I’m not aware of anybody committed to systematically backport patches to compilers on the opam repository, but you could try asking one of the maintainers for this specific patch if it’s important to you.

Thank you, it’s good to know that it has been fixed.

As this was a one shot problem, I simply renamed the directory.