Ocaml Software on Android – Without root

May 19th, 2022 by Christophe Grévent Leave a reply »

Since I use smartphones and tablets, I try to get a working ocaml world on it, as ocaml is the language I use for all kind of programming… And I was always disappointed as it did not work properly.

A few days ago, I started a new try, using my venerable Galaxy Tab S2 (that was replaced by a Surface Go 2) for this experiment. And yes, this time it worked. And, it is nice… So, just here my experience.

  • In a first step, I installed the termux app from the Android store (or some alternative store). This is just as straight forward as for all other apps.
  • Then, I installed the two packages proot and proot-distro (pkg install proot proot-distro, then confirming the installation). The tool proot fakes the environment to look like linux as root to the applications. proot-distro uses proot, and installs an environment corresponding to a standard linux.
    • Just as a notice, termux is a very reduced environment. For standard software present (I think python stuff for instance), it may be enough. But, for instance, it does not use libc, uses clang / llvm, etc. The choices are OK, but for the purpose of installing a linux-like ocaml environment, it seems too reduced. Probably I would have to tweak the ocaml environment, but it seemed too much work to me.
  • As I’m a debian user, I installed a debian environment with the command proot-distro install debian.
  • Then I started the debian environment using proot-distro login debian
  • From this point, I updated the debian packages present, installed opam, the standard package manager for ocaml stuff.
    • I must admit, that it is quite astonishing to me to see the typical debian ncurses work on the display of my smartphone / tablet. BUT, don’t forget, it is NOT a full standard debian environment. The accesses to /proc are simulated by proot, and some other stuff with the files (related to rights of the android filesystem I think) don’t work as on a full debian install!
  • Then, I started opam init –disable-sandboxing
    • Disabling the sandboxing is needed exactly for the reason described previously. Termux / proot don’t propose the full functionality needed for this purpose
  • opam switch install 4.13.0 for installing the ocaml version 4.13.0. Feel free to replace the version with the version you need.
  • For standard stuff, it works like a normal opam installation. I personally run in a problem as I use libraries in my repository, and pinned the libraries in the development environment. For this, I use git as recommended. To make it short: This does not work on this install, for obscure reasons to me, there is a problem with the file system… The workaround for me was to make a local repository, to publish the packages to it, and install them from there. At the end, a little more work, but OK as the libraries should be published on a later step.

Hope it will help you!

Kind regards,

Christophe

-->

Comments are closed.