OCaml: Can't run utop after installing it

試著忘記壹切 提交于 2019-12-04 03:01:40

Regarding utop, it seems that you don't have in your $PATH. Did you do:

$ eval `opam config env`

If you want opam to be correctly automatically setup in your new shells you should add the following to your .bashrc:

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

As for not being able to open Core.Std, you won't of course be able to open it in your shell, this command must be issued in utop.

The methods to install OCaml utop in ubuntu in most of the online resources seem like kind of misleading users. The thing is when installing opam with sudo apt-get command there is no need to install OCaml again using same command because OCaml came with opam installation. so only thing you have to do is to correctly initialize the state of the opam which defines the OPAM root in your home folder.

So if you have installed any OCaml earlier first remove them to avoid conflicts.

sudo apt-get purge --auto-remove ocaml-source
sudo apt-get purge opam

then install opam.

sudo add-apt-repository ppa:avsm/ppa
sudo apt-get update
sudo apt-get install opam

initialize the state of the opam

opam init

if it shows a dependency missing warning try this commands,

opam install depext
opam depext conf-m4.1

then verify ocaml installation,

eval 'opam config env'
ocaml

install UTop then,

opam install utop
eval `opam config env`
utop

for detailed information and handle errors please refer this blog post.

So, I did try eval 'opam config env' and this is what happens:

$ eval 'opam congif env'
CAML_LD_LIBRARY_PATH="/home/jharvard/.opam/4.01.0/lib/stublibs"; export CAML_LD_LIBRARY_PATH; 
PERL5LIB="/home/jharvard/.opam/4.01.0/lib/perl5"; export PERL5LIB;
OCAML_TOPLEVEL_PATH="/home/jharvard/.opam/4.01.0/lib/toplevel"; export OCAML_TOPLEVEL_PATH;
MANPATH="/home/jharvard/.opam/4.01.0/man:"; export MANPATH; PATH="/home/jharvard/.opam/4.01.0/bin:/etc/log50.d:/etc/log50.d:/usr/lib/qt-3.3/bin:/etc/log50.d:/usr/libexec/lightdm:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/jharvard/.local/bin:/home/jharvard/bin"; export PATH;

And then it still says that the "utop" command is not found. The paths above are gibberish to me. Would anyone be able to look at what it returned to see if that indicates what the problem might be?

My Ubuntu-14 / Mint was also "borked"

After reading Ubuntu section here ; https://opam.ocaml.org/doc/Install.html

AND removing .opam/ dir before again doing;

  1. opam init
  2. opam install utop

fixed it !

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!