Search code examples
bashocamlubuntu-14.04opam

Problems using opam and ocaml


I am working on RDP having Ubuntu 14.04 and trying to install ocaml.

I am trying to update my ocaml compiler to 4.05.0 or above but opam switch list gives only one compiler system C system System compiler (4.01.0). Also my opam update gives me below log.

[ERROR] Your version of OPAM (1.1.1) is not recent enough to read ~/.opam/repo/default/repo. Upgrade OPAM to a more recent version (at least 2.0) to read this file correctly.
[ERROR] Skipping https://opam.ocaml.org as the repository is not available.
Updating ~/.opam/repo/compiler-index ...
Updating ~/.opam/compilers/ ...
Updating ~/.opam/repo/package-index ...
Updating ~/.opam/packages/ ...
Updating the cache of metadata (~/.opam/state.cache) ...
Everything is up-to-date.

Any idea how to do this? Thanks for help in advance.

UPDATE: I need to install newer opam version separately using binary distribution. with this

sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) 

command I can install it but it will prompt me where to install it, but I have to automate installation so that there is no interaction from user side. Is there a way to do it?

UPDATE 2:

found a way to do it using ppa see my answer.


Solution

  • I tried using sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) but failed in doing it as non-interactive script.

    I have found this method which does work, though using Ubuntu 14.04 adding ppa sudo add-apt-repository ppa:avsm/ppa and then doing update, upgrade, dist-upgrade and finally installation of opam will be of version 2.2 (latest as by ppa). Follow below commands for exact procedure.

    add-apt-repository ppa:avsm/ppa
    apt-get update -y
    apt-get upgrade -y
    apt-get dist-upgrade -y
    apt-get install curl build-essential m4 zlib1g-dev libssl-dev ocaml ocaml-native-compilers opam -y
    opam init --disable-sandboxing -y
    eval `opam config env`
    opam update
    opam switch list-available
    opam switch create 4.07.0
    opam init -y
    eval `opam config env`
    

    After this Everything should be latest as of now.