Skip to content

compiling ocaml in a folder with space in its name creates a binary with an invalid shebang #12709

@Khady

Description

@Khady

Following on #11590, it is possible to install ocaml in a folder with spaces, but if that ocaml was compiled in a folder with spaces it will contain an invalid shebang.

See original investigation in ocaml/opam#5679, thanks to @kit-ty-kate for the help. Here are the steps to reproduce:

Creating a new switch from /tmp/my folder with spaces:

/tmp/my folder with spaces$ opam sw create . 5.1.0 --keep-build

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml-base-compiler" {= "5.1.0"} | "ocaml-system" {= "5.1.0"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
∗ installed ocaml-options-vanilla.1
⬇ retrieved ocaml-base-compiler.5.1.0  (cached)
∗ installed ocaml-base-compiler.5.1.0
∗ installed ocaml-config.3
[ERROR] The compilation of ocaml.5.1.0 failed at "ocaml /tmp/my folder with spaces/_opam/share/ocaml-config/gen_ocaml_config.ml 5.1.0 ocaml".

#=== ERROR while compiling ocaml.5.1.0 ========================================#
# context     2.2.0~alpha2 | linux/x86_64 | ocaml-base-compiler.5.1.0 | https://opam.ocaml.org#ad6e2e17
# path        /tmp/my folder with spaces/_opam/.opam-switch/build/ocaml.5.1.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build ocaml /tmp/my folder with spaces/_opam/share/ocaml-config/gen_ocaml_config.ml 5.1.0 ocaml
# exit-code   1
# env-file    ~/.opam/log/ocaml-2141670-5e79cc.env
# output-file ~/.opam/log/ocaml-2141670-5e79cc.out
### output ###
# bwrap: execvp ocaml: No such file or directory



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml 5.1.0
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray         base
│ ∗ install base-threads          base
│ ∗ install base-unix             base
│ ∗ install ocaml-base-compiler   5.1.0
│ ∗ install ocaml-config          3
│ ∗ install ocaml-options-vanilla 1
└─ 
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n] n

No such file or directory is the output of the ocaml binary. If the clean up offered by opam was rejected, it is possible to reproduce the error by hand with

/tmp/my folder with spaces$ _opam/bin/ocaml
-bash: _opam/bin/ocaml: /tmp/my: bad interpreter: No such file or directory

The problem seems to come from the first line of the ocaml executable, which is the following:

#!/tmp/my folder with spaces/_opam/bin/ocamlrun

According to https://lists.gnu.org/archive/html/bug-bash/2008-05/msg00052.html it is not possible to have a shebang path with spaces in it. So there's probably no good solution. But I thought it could be worth reporting anyway.

Metadata

Metadata

Assignees

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