Installing OCAML on Windows 10 using WSL (UBUNTU). Problems with bwrap (BubbleWrap)
Asked Answered
A

2

5

I'm a novice to Linux and OCAML. I gather that getting OCaml working on Windows is not straight forward. I found this link:

https://www.cs.umd.edu/class/spring2018/cmsc330/ocamlInstallationGuide.pdf#page=14&zoom=100,0,96

However, I suspect it's some what dated as they refer to 4.04 being the latest OCaml version and there currently is a 4.07. I further suspect that OCaml now requires bwrap and that is the source of my problems and question.

I stress that I just want to get OCaml working on Windows. If there is a much easier way than using WSL (Windows Subsystem for Linux), I'll happily do that.

When creating a switch with:

opam switch create ocaml-base-compiler.4.07.0,

I get the following error:

bwrap: Creating new namespace failed, likely because the kernel does not support user namespaces. bwrap must be installed setuid on such systems.

I gather I need bwrap and have tried various commands such as:

wget https://mirrors.edge.kernel.org/ubuntu/pool/main/b/bubblewrap/bubblewrap_0.3.1-2_amd64.deb

followed by:

sudo dpkg -i bubblewrap_0.3.1-2_amd64.deb

Installation appeared to go fine but I still get the error. I must admit I don't know what bwrap must be installed setuid on such systems means.

1) How should I install bwrap?

This site:

https://github.com/projectatomic/bubblewrap/issues/139

seems to indicate it may not be possible to get bwrap working on Windows period: "Flatpak and bubblewrap require Linux. WSL is not Linux, it's Windows pretending to be Linux, and it does not have the full feature-set of a modern Linux kernel. As far as I am aware, it doesn't implement namespaces, so you are out of luck."

2) Can I get OCaml up and running on Windows using WSL or is there a better approach?

Finally, I'm not wedded to Ubuntu. If there is a better/easier distribution to use with WSL for purposes of installing OCAML I have no problems changing!

Thanks, Dave

Airt answered 4/3, 2019 at 16:8 Comment(3)
Did you consider using Opam -e.g. on your Ubuntu?Health
Read also about installing Ocaml on Windows (then you could use Ocaml without WSL)Health
Yes, installing Opam is part of the directions indicated on my first referenced document. Thanks!Airt
A
6

Here is what I did to get things working. Based on this comment:

"I can work around this by wiping out ~/.opam/config, I think, and using opam init --disable-sandboxing, but that's somewhat less than an ideal user-experience."

https://github.com/ocaml/opam/issues/3505

and this instruction:

"Indeed, bwrap is not supported by WSL (cf. this issue). To be able to use opam in your case, you can disable sandboxing (use with caution) using the --disable-sandboxing option for a fresh opam initialisation or via an opamrc. For an initialised opam, you can't use this option, but change the configuration directly in the config file by removing / empty wrap-*-commandfields. See this faq entry for further information. And I repeat the warning here: "Use [sanbdoxing disable option] wisely, broken Makefiles that run rm -rf / do happen.""

from:

https://opam.ocaml.org/doc/FAQ.html#Why-does-opam-require-bwrap

I wiped out the .opam directory and did a

opam init --disable-sandboxing

before doing this I did a:

rm -r .opam

I'll mention again all the warnings about turning off sandboxing being dangerous (see links).

I'm now using OCaml 4.07.0 !!!

Hope this helps somebody

Airt answered 5/3, 2019 at 11:5 Comment(1)
Had the same issue with Deban bullseye for armhf in a foreign chroot jail on Ubuntu 22.02 on Github Actions. Same error message, adding --disable-sandboxing to opam init fixed this.Beatitude
M
1

More modern guidance (tested on WSL2 Ubuntu 20.04) can be found on the Jane Street Install OCaml repo.

Marginate answered 25/5, 2020 at 23:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.