Your first app in 5 minutes ? no

I tried to follow the instructions on this page :
https://ocsigen.org/tuto/6.2/manual/start
and the installation instructions for debian based (I’m on linux mint 19) did not permit me to install ocsigen.
I’m totally new to ocaml. A sudo apt-get install ocaml seems to be missing.
I issued the following commands :

sudo apt-get install ruby-sass
sudo apt-get install postgresql
sudo apt-get install ocaml
sudo apt-get install opam
opam init
opam install ocsigen-start

But this is not enough, eliom-distillery -name myapp -template os.pgocaml does not work.
And I checked du -sh ~/.opam/ : 720M !

In such circumstances, my natural reflex is to think “ok, this techno is not mature, ciao”.
The “first app” is the first impression one has on a new techno, so I think it should be very carefully written and tested.

Can someone tell me what’s wrong ? Thank you

2 Likes

I can’t talk about ocsigen but I found Opam not to be space efficient. If you look around, it keeps installed packages as source trees and all compilation artefacts. My own ~/.opam with a single switch and 300 or so packages consumes 3.7GB.

Can you describe why?

Because command does not exist.
which eliom-distillery returns nothing

It could be a path issue. Can you either

  1. reopen your terminal and check again (I suppose that opam wanted to write something to your .bashrc and you agreed)
  2. execute eval $(opam config env) or something to reevaluate paths.

Just a side note: at current disk prices, 1GB of storage is either $0.03 worth of spinning rust or about $0.15 worth of SSD. Worrying about a couple of gigs of storage is literally worrying about the amount of money a minimum wage earner makes in well under a minute, and indeed, far less than any programmer should ever care about. If “wasting” a few gigs of storage saves you even a minute or two of your life, it’s economically more than paid for itself.

1 Like

If Opam just sits in your $HOME I would agree. But when you use Opam in containers and in build environments that are frequently re-created and torn down, you start to feel the volume transferred over the network. I think Opam is the best thing that happened to the community but this does not mean it is ideal for all scenarios.

1 Like

Re-building a container from scratch using a source based build system is probably a mistake. If people really want to construct deployment binaries for containers using opam (which is not an unreasonable desire), we should probably come up with a method for constructing pre-compiled binary packages in a clean build container using opam as the build system, and then people can just blat the built packages in to the destination containers.

Here is what I have now :

opam config env
CAML_LD_LIBRARY_PATH="/home/thierry/.opam/system/lib/stublibs:/usr/lib/ocaml/stublibs"; export CAML_LD_LIBRARY_PATH;
MANPATH="/home/thierry/.opam/system/man:"; export MANPATH;
PERL5LIB="/home/thierry/.opam/system/lib/perl5"; export PERL5LIB;
OCAML_TOPLEVEL_PATH="/home/thierry/.opam/system/lib/toplevel"; export OCAML_TOPLEVEL_PATH;

I tried to add to add in ~/.bashrc :
export PATH=$PATH:$OCAML_TOPLEVEL_PATH

and
source ~/.bashrc

I see ~/.opam/system/bin in $PATH

but still :
eliom-distillery -name myapp -template os.pgocaml
eliom-distillery : command not found

In ~/.opam/system/bin there are ocaml and ocsigen binaries but no eliom

The only place I find traces of “eliom” in ~/.opam is
.opam/repo/default/archives/eliom.6.3.0+opam.tar.gz
.opam/repo/default/packages/eliom
.opam/repo/default/packages/eliom/eliom.2.2.2

Have you tried opam install eliom?

opam clean -a
1 Like

Also do you have that line (or something similar) in your ~/.bashrc?

. /home/thierry/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true

Thanks for your helps. I tried several things, but it still doesn’t work. I will uninstall for the moment. I’m following the mooc at fun-mooc.fr (Introduction to Functional Programming in OCaml) and it’s possible to use the online REPL. I tried to install ocmal locally to test ocsigen.
The main reason is the question of space, the “side note” of perry.
First, if I want more space on my local machine, I need to buy a 512 SSD, which is 100 euros, so money is a concern.
But more important is the fact that these 721 Mo are stored in my home, so they will be included in backups, and I try to backup only things that need to be backuped.
At least for me, the location of .opam is blocking ; I tried haskell this summer and could write small programs locally. Maybe it was also 700 Mo but I didn’t notice it as it was stored in /usr and other system locations.

It’s very likely that your opam installation is not properly initialized. I recommend following the installation instructions included in Real World OCaml: https://dev.realworldocaml.org/install.html

In many places, people undergo quota restrictions… So the size of a local opam installation does matter.

ok, I removed ~/.opam and followed the instructions from realworldocaml.org and it worked.

I fixed the problem of space occupied by ~/.opam in my home doing something ugly :
cd ~
sudo mv .opam /usr/opam
ln -s /usr/opam .opam
It seems to work

Ocsigen install still doesn’t work because some packages installation failed (conf-gmp.1 conf-libpcre.1 sqlite3.4.3.2) but it’s not important for the moment. I’m just a newbie, a programmer used to imperative languages who starts to realize that functional programming can’t be neglected anymore. I’ll come back to ocsigen when I’m more familiar with opam and ocaml ecosystem.

I’m curious, how does moving opam from one part of your disk to another help things?

@tig12 the conf-* family of packages are meant to check the presence of external dependencies, i.e., dependencies managed by your system and not opam. You can either install those dependencies manually with brew, apt or whatever package manager you use, or ask opam to help you (it might not work for all packages). For more info see: https://opam.ocaml.org/doc/FAQ.html#Some-package-fail-during-compilation-complaining-about-missing-dependencies-quot-m4-quot-quot-libgtk-quot-etc.

My guess is that it’s a different disk