'opam install uri' failed - ocaml

I'm trying to install the uri package for Opam but I keep running in to this error.
==== ERROR [while installing uri.1.3.8] ====
# opam-version 0.9.6 (latest-103-g955b7ca)
# os linux
# command ocaml setup.ml -configure --prefix /root/.opam/system
# path /root/.opam/system/build/uri.1.3.8
# exit-code 1
# env-file /root/.opam/system/build/uri.1.3.8/uri-ffb3fd.env
# stdout-file /root/.opam/system/build/uri.1.3.8/uri-ffb3fd.out
# stderr-file /root/.opam/system/build/uri.1.3.8/uri-ffb3fd.err
### stderr ###
ocamlfind: Package `compiler-libs.toplevel' not found
W: Field 'pkg_compiler_libs_toplevel' is not set: Command ''/root/.opam/system/bin/ocamlfind' query -format %d compiler-libs.toplevel > '/tmp/oasis-85d951.txt'' terminated with error code 2
E: Cannot find findlib package compiler-libs.toplevel
E: Failure("1 configuration error")
'opam install uri' failed.
I'm pretty new to Ocaml and the Opam repo. I really have no idea what is going wrong. I am running Ubuntu 12.04 and have Ocaml 3.12.1 installed.
Thanks for any insight you can provide!

I just installing uri under 3.12.1 without any issues.
3.12.1 is under your system ocaml compiler, right? and you probably installed ocaml via aptitude? In which case you need to also install ocaml-compiler-libs. There are a number of other optional packages for OCaml that are usually needed and may run into in the future --camlp4-extra is another that I see missed and oft needed. A maximal list is here.
I would also upgrade OPAM, since there were some changes to the uri package only two days ago. opam update; opam upgrade. This will require some re-compilation, and make sure you switched to the correct compiler.

The package "compiler-libs.toplevel" is missing. If I remember right, it's shipped together with ocaml and is available only since version 4.0.
Either install an older version of uri or update your compiler to 4.0. For details look here

Related

How to build OCaml in M1 Mac with Zarith on it?

I am trying to do code generation with Isabelle/HOL in an M1 Mac computer. A recurring issue to achieve this relates to OCaml's library Zarith. I've asked in their mailing list and their answer was that "the problem is
ultimately to build OCaml (with Zarith) on it". Unfortunately, I do not understand what the verb "build" means in that sentence. OCaml is in that computer as the report on the end of this question indicates. The computer has Zarith on it (version 1.12). However, as they say, there is an issue with Zarith in that system. The evidence that I have for this comes from two observations:
When I run utop and do #require "zarith";; the answer is:
Cannot load required shared library dllzarith.
Reason: /.../.opam/ocaml-base-compiler.4.12.0/lib/stublibs/dllzarith.so: dlopen(/.../.opam/ocaml-base-compiler.4.12.0/lib/stublibs/dllzarith.so, 0x000A): symbol not found in flat namespace '___gmpn_add_n'.
When opening an .ml file in Visual Studio Code with commands with types such as Z.t where Z represents Zarith, VSC complains with Unbound module Z ocamllsp.
The question is then, how do I make this computer find the Zarith files it needs to work properly?
% opam config report
# opam config report
# opam-version 2.0.8
# self-upgrade no
# system arch=arm64 os=macos os-distribution=homebrew os-version=12.0.1
# solver builtin-mccs+glpk
# install-criteria -removed,-count[version-lag,request],-count[version-lag,changed],-changed
# upgrade-criteria -removed,-count[version-lag,solution],-new
# jobs 7
# repositories 1 (http) (default repo at 8818dcc3)
# pinned 0
# current-switch ocaml-base-compiler.4.12.0

Why can't opam install the graphics package?

I tried to install the ocaml graphics package, but it fails. Any suggestions for how I can fix it?
~/Documents/Work/Code/OCaml with graphics: opam update
=-=- Updating package repositories =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
[default: http] Command started
[default: http] Command started
[default] synchronized from https://opam.ocaml.org
~/Documents/Work/Code/OCaml with graphics: opam upgrade
Already up-to-date.
~/Documents/Work/Code/OCaml with graphics: opam install graphics
The following actions will be performed:
∗ install graphics 1.0
=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
[graphics: ocamlc graphics.cma] Command started
[ERROR] The compilation of graphics failed at "ocamlc -custom graphics.cma -o
test".
#=== ERROR while installing graphics.1.0 ======================================#
# opam-version 1.2.2
# os darwin
# command ocamlc -custom graphics.cma -o test
# path /Users/Tim/.opam/system/build/graphics.1.0
# compiler system (4.04.0)
# exit-code 2
# env-file /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.env
# stdout-file /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.out
# stderr-file /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.err
### stderr ###
# File "_none_", line 1:
# Error: Cannot find file graphics.cma
=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
The following actions failed
∗ install graphics 1.0
No changes have been performed
=-=- graphics.1.0 troubleshooting -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
=> This package checks whether the Graphics library was compiled.
Other than the missing graphics package, my ocaml install is working fine.
Here are the contents of the files in ~/.opam/system/build/graphics.1.0
First, graphics-14648-7afd23.err:
File "_none_", line 1:
Error: Cannot find file graphics.cma
Then graphics-14648-7afd23.info:
# opam-version 1.2.2
# os darwin
# command ocamlc -custom graphics.cma -o test
# path /Users/Tim/.opam/system/build/graphics.1.0
# compiler system (4.04.0)
# env-file /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.env
# stdout-file /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.out
# stderr-file /Users/Tim/.opam/system/build/graphics.1.0/graphics-14648-7afd23.err
And graphics-14648-7afd23.env:
PATH=/Users/Tim/.opam/system/bin:/Library/Frameworks/Python.framework/Versions/3.2/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/usr/local/bin
OCAML_TOPLEVEL_PATH=/Users/Tim/.opam/system/lib/toplevel
PERL5LIB=/Users/Tim/.opam/system/lib/perl5:
MANPATH=/Users/Tim/.opam/system/man:/opt/local/share/man:
OPAMSWITCH=system
OPAMUTF8MSGS=1
CAML_LD_LIBRARY_PATH=/Users/Tim/.opam/system/lib/stublibs:/usr/local/lib/ocaml/stublibs
SHELL=/bin/bash
TERM=dumb
TMPDIR=/var/folders/kv/kmn525v16kb2mz2hrhq3q4mh0000gn/T/
BASHRC_HAS_BEEN_RUN=1
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.8tP8Ej926f/Render
EMACSDATA=/Applications/Emacs.app/Contents/Resources/etc
OLDPWD=/Users/Tim/Documents/Work/Code
EMACSPATH=/Applications/Emacs.app/Contents/MacOS/bin
USER=Tim
EMACS=t
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.EXKwsf0Dz0/Listeners
TERMCAP=
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
COLUMNS=190
BASH_PROFILE_HAS_BEEN_RUN=1
PWD=/Users/Tim/Documents/Work/Code/OCaml with graphics
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
EMACSLOADPATH=/Applications/Emacs.app/Contents/Resources/site-lisp:/Applications/Emacs.app/Contents/Resources/lisp:/Applications/Emacs.app/Contents/Resources/leim
SHLVL=1
HOME=/Users/Tim
LOGNAME=Tim
INFOPATH=/Applications/Emacs.app/Contents/Resources/info:
DISPLAY=/private/tmp/com.apple.launchd.jPYPDR7RIj/org.macosforge.xquartz:0
INSIDE_EMACS=23.1.1,comint
EMACSDOC=/Applications/Emacs.app/Contents/Resources/etc
_=/usr/local/bin/opam
OPAM_PACKAGE_VERSION=1.0
OPAM_PACKAGE_NAME=graphics
MAKELEVEL=
MAKEFLAGS=
The final file, graphics-14648-7afd23.env, is empty.
Edit: this answer didn't solve OP's problem. But I think this answer is still valuable, so I leave this here.
Install the OCaml compiler via OPAM, using opam switch <version number here> (Available version numbers are shown by opam switch). The graphics package is a virtual package to check the availability of the Graphics library, so opam install graphics will fail if there is no library on system's OCaml.
You can confirm the existence of the Graphics library by running ls ~/.opam/*/lib/ocaml/graphics.cma. If no file is found, then Graphics is not installed and therefore the failure of installation is the valid behavior. I don't know the exact reason why Graphics isn't installed, but maybe it's important that Graphics needs X11 to be installed. Especially, it's necessary to install XQuartz on macOS. See Shoe's answer for details. Also, re-installation of OCaml via OPAM will be needed after that. We can reinstall OCaml by running:
opam switch reinstall <version number here>

Could not install sudo apt-get install libshogun17

When trying to install shogun im getting this error. Can some one suggest a solution?
N: Ignoring file '50unattended-upgrades.ucf-dist' in directory '/etc/apt/apt.conf.d/' as it has an invalid filename extension
E: Unable to locate package libshogun17
Im using ubuntu operating system.
See this explanation of the origin and purpose of .ucf-dist files. This means you can either ignore the notice (that's what the N: prefix stands for) or remove said file.
sudo rm /etc/apt/apt.conf.d/50unattended-upgrades.ucf-dist
libshogun17 is not part of ubuntu by default. Currently we supply two different ppa's for xenial and trusty:
for nightly builds: https://launchpad.net/~shogun-toolbox/+archive/ubuntu/nightly
for stable releases: https://launchpad.net/~shogun-toolbox/+archive/ubuntu/stable
please follow the instruction either the given page or http://shogun.ml/install#ubuntu how to add the ppa to your system.
Note, as mentioned above those PPAs only supply packages for ubuntu trusty or xenial.

not able to install anything using opam

I installed opam with homebrew on Mac OS X 10.10. But I can't install anything using opam. This is an example error output that get when I try to install ocamlfind:
# opam-version 1.2.0
# os darwin
# command ./configure -bindir /Users/roger/.opam/system/bin -sitelib /Users/roger/.opam/system/lib -mandir /Users/roger/.opam/system/man -config /Users/roger/.opam/system/lib/findlib.conf -no-topfind
# path /Users/roger/.opam/system/build/ocamlfind.1.5.5
# compiler system (4.02.1)
# exit-code 1
# env-file /Users/roger/.opam/system/build/ocamlfind.1.5.5/ocamlfind-91360-c61e7b.env
# stdout-file /Users/roger/.opam/system/build/ocamlfind.1.5.5/ocamlfind-91360-c61e7b.out
# stderr-file /Users/roger/.opam/system/build/ocamlfind.1.5.5/ocamlfind-91360-c61e7b.err
### stdout ###
# ...[truncated]
# Configuration for str written to site-lib-src/str/META
# Configuration for threads written to site-lib-src/threads/META
# Configuration for unix written to site-lib-src/unix/META
# Configuration for stdlib written to site-lib-src/stdlib/META
# Configuration for bigarray written to site-lib-src/bigarray/META
# Configuration for camlp4 written to site-lib-src/camlp4/META
# Configuration for ocamlbuild written to site-lib-src/ocamlbuild/META
# Configuration for compiler-libs written to site-lib-src/compiler-libs/META
# Configuration for bytes written to site-lib-src/bytes/META
# Detecting compiler arguments: FAILED (see the file ocargs.log for details)
### stderr ###
# ./configure: line 547: cd: src: No such file or directory
brew install opam
opam init --comp=4.02.1
eval `opam config env`
ocaml
Update:
Sometimes brewed opam can fail with Illegal Instruction, in that case you need to reinstall opam from sources:
brew reinstall --build-from-source opam
Also, you need a working toolchain, i.e., compiler, autotools and other developer tools. You can try to install it using brew, e.g., brew install autotools, etc. Or you can try to install xcode toolchain, including apple command line developer tools.
I had the same problem trying to install mirage, the problem is because the current directory is not in the CDPATH by default on macOS X. The posix /bin/sh will not "cd src" though can "cd ./src". The quick fix is to do the following before running opam (or just put it in your .bash_profile.
export CDPATH=.
opam install WHATEVER

Installing Camomile via opam fails due to missing patch file. How can I fix this?

While installing utop via opam on my ArchLinux laptop, I got the following message:
$ opam install utop
The following actions will be performed:
- install camomile.0.8.5 [required by utop]
- install zed.1.3 [required by utop]
- install lambda-term.1.6 [required by utop]
- install utop.1.14
4 to install | 0 to reinstall | 0 to upgrade | 0 to downgrade | 0 to remove
Do you want to continue ? [Y/n]
=-=-= Installing camomile.0.8.5 =-=-=
Applying cmxs.patch.
[ERROR] Due to some errors while processing camomile.0.8.5, the following actions will NOT proceed:
- install utop.1.14
- install lambda-term.1.6
- install zed.1.3
===== ERROR while installing camomile.0.8.5 =====
Could not get the source for camomile.0.8.5:
# opam-version 1.1.1
# os linux
Patch file "/home/sinan/.opam/system/build/camomile.0.8.5/cmxs.patch" not found.
'opam install utop' failed.
Trying to install camomile by itself also gives the same error. This seems to be related to commit 672e44e which carried over to the opam repository as cmxs.patch. I am not sure where things break so that opam tries to build without the patch file.
I tried downloading, and putting cmxs.patch in the reported location, but, of course, that directory gets clobbered the next time I try to install via opam.
How should I proceed?
I would have preferred to have been able to fix the underlying problem, but, in the end, downloading the contents of the cmxs.patch file, adding it to the already downloaded ~/.opam/archives/camomile.0.8.5+opam.tar.gz archive, and then issuing
$ opam install camomile
worked.
After that, opam install utop went without a hitch as well.
For your reference, I have:
$ opam --version
1.1.1
$ cat .opam/repo/default/repo
upstream: "https://github.com/ocaml/opam-repository/tree/master/"
browse: "https://opam.ocaml.org/pkg/"