Divers

Installer utop sur Mageia 6

Dernière mise à jour : 05/09/2024 à 16h07
Table des matières

Installer utop sur Mageia


Rédigé pour Mageia 6. Mis à jour pour Mageia 9.

Introduction



utop est un interpréteur ( un toplevel ; utop c'est Universal Toplevel ) pour le langage de programmation OCaml qu'on peut lancer dans un terminal.
ocaml est l’interpréteur par défaut, mais malheureusement il est franchement sommaire.
Code TEXT :
ocaml
        OCaml version 4.14.0
# 5+6;;
- : int = 11
# 45 + 8;;
- : int = 53
# ^[[A

Voilà ce qu'on obtient, dernière ligne, en essayant de rappeler la commande précédente avec la touche <>.

utop est plus souple , et plus coloré.

screenshot_20170901_002150




Installation



utop est dans les dépôts


Mais ça ne fonctionne pas. L'installation de passe bien, mais
Code BASH :
$ utop
Fatal error: cannot load shared library dlllambda-term_stubs
Reason: dlllambda-term_stubs.so: cannot open shared object file: No such file or directory

Le bug est déclaré, mais il n'y a plus de mainteneur, actuellement, pour les rpm OCaml.
Le post du forum en rapport avec ce problème.

Installation sans les dépôts


Voici une méthode non exclusive d'une autre a priori. Je présente ici un tutoriel issu d'une démarche empirique.
D'autres démarches peuvent fonctionner ou pas.
Pour résumer voici comment j'ai obtenu utop sous mageia 6.

Installer opam

opam est un gestionnaire de paquets pour OCaml, comme l'est pip (ou pip3) pour python (pour python 3).
Pas de problèmes, il est dans les rpm Mageia 6 (et 9). Donc
Code BASH :
# urpmi opam

Il faut ensuite le paramètrer (commande, et messages) :
Code BASH :
$ opam init

Caché :
$ opam init
OPAM has already been initialized.
In normal operation, OPAM only alters files within ~/.opam.
During this initialisation, you can allow OPAM to add information to two
other files for best results. You can also make these additions manually
if you wish.
If you agree, OPAM will modify:
- ~/.bash_profile (or a file you specify) to set the right environment
variables and to load the auto-completion scripts for your shell (bash)
on startup. Specifically, it checks for and appends the following line:
. /home/dom/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
- ~/.ocamlinit to ensure that non-system installations of `ocamlfind`
(i.e. those installed by OPAM) will work correctly when running the
OCaml toplevel. It does this by adding $OCAML_TOPLEVEL_PATH to the list
of include directories.
If you choose to not configure your system now, you can either configure
OPAM manually (instructions will be displayed) or launch the automatic setup
later by running:
opam config setup -a
Do you want OPAM to modify ~/.bash_profile and ~/.ocamlinit?
(default is 'no', use 'f' to name a file other than ~/.bash_profile)
[N/y/f]

Choisissez Yes.
Installer utop via opam

On doit pouvoir installer utop à l'aide d'opam.
Code BASH :
opam install utop

Mais, ça n'a pas fonctionné pour moi. J'ai l'erreur
Code BASH :
[ERROR] The compilation of ocamlfind failed at "make all".

Une erreur sur ocamlfind très connue de Google.

Pour info, voici ce vous installez avec utop, si vous ne rencontrez pas ce bug.
Caché :
Code BASH :
$ opam install utop          
The following actions will be performed:
  ∗  install base-ocamlbuild base             [required by ocamlbuild]install conf-m4         1                [required by ocamlfind]install result          1.2              [required by lwt]install ocamlbuild      0                [required by cppo, lambda-term]install ocamlfind       1.7.3            [required by utop]install topkg           0.9.0            [required by react]install ppx_tools       5.0+4.02.0       [required by lwt]install jbuilder        1.0+beta12       [required by utop]install cppo            1.4.0            [required by utop]install react           1.2.1            [required by utop]install camomile        0.8.5            [required by zed]install lwt             2.7.1            [required by utop]
       For module Lwt_react, please install package lwt_react
  ∗  install zed             1.3              [required by lambda-term]install lambda-term     1.10.1           [required by utop]install utop            2.0.1     
===== ∗  15 =====
Do you want to continue ? [Y/n] y
 


Autre démarche

J'ai contourné le problème ci dessus avec
Code BASH :
opam switch install 4.02.1

Au 05/09/2024, on peut choisir la version 5.1.1
Qui retrourne
Caché :
=-=- Installing compiler 4.02.1 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[default.comp] http://caml.inria.fr/pub/distrib/ocaml-4.02/ocaml-4.02.1.tar.gz downloaded
Now compiling OCaml. This may take a while, please bear with us...
Done.

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
installed base-bigarray.base
installed base-ocamlbuild.base
installed base-threads.base
installed base-unix.base
Done.
# To setup the new switch in the current shell, you need to run:
eval `opam config env`

Par conséquent
Code BASH :
$ eval `opam config env`


On installe maintenant utop :
Caché :
Code BASH :
$ opam install utop     
The following actions will be performed:
  ∗  install ocamlbuild  0                    [required by utop]install conf-m4     1                    [required by ocamlfind]install result      1.2                  [required by lwt]install ocamlfind   1.7.3                [required by utop]install topkg       0.9.0                [required by react]install ppx_tools   5.0+4.02.0           [required by lwt]install cppo        1.4.0                [required by utop]install react       1.2.1                [required by utop]install camomile    0.8.5                [required by zed]install lwt         2.7.1                [required by utop]
       For module Lwt_react, please install package lwt_react
  ∗  install zed         1.3                  [required by lambda-term]install lambda-term 1.10.1               [required by utop]install utop        1.19.3    
===== ∗  13 =====
Do you want to continue ? [Y/n] y
=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[camomile] Archive in cache
[cppo] Archive in cache
[lambda-term] Archive in cache
[lwt] Archive in cache
[ocamlfind] Archive in cache
[ppx_tools] Archive in cache
[react] Archive in cache
[topkg] Archive in cache
[zed] Archive in cache
[default] https://opam.ocaml.org/archives/result.1.2+opam.tar.gz downloaded
[default] https://opam.ocaml.org/archives/utop.1.19.3+opam.tar.gz downloaded
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
∗  installed ocamlbuild.0
∗  installed conf-m4.1
∗  installed result.1.2
∗  installed ocamlfind.1.7.3
∗  installed cppo.1.4.0
∗  installed ppx_tools.5.0+4.02.0
∗  installed topkg.0.9.0
∗  installed react.1.2.1
∗  installed lwt.2.7.1
∗  installed camomile.0.8.5
∗  installed zed.1.3
∗  installed lambda-term.1.10.1
∗  installed utop.1.19.3
Done.
 

Et cette fois, c'est la bonne !

Confession



Je n'ai pas recherché les causes des différents bugs.
Et je confesse que je ne vous propose aucune explication ou solution aux bugs rencontrés. Ni pour le bug du package Mageia, ni pour le bug ocamlfind.


Webographie




Meuz, le 31/08/17. MaJ le 05/09/24


Cette page a été vue 4471 fois