mac os zarith problem

I am using macos monterey 12.6 on a mac mini m1. I use the ocaml language quite a bit on linux mint, and was trying to get it working on the m1.

My programs (from linux) use package zarith (which is a multiple precision package). brew only allows an install of ocaml-zarith, not zarith. I installed opam with brew, and tried

opam install zarith

which gives the error:

#=== ERROR while compiling zarith.1.12 ========================================#

context 2.1.3 | macos/arm64 | ocaml.4.14.0 |
path ~/.opam/default/.opam-switch/build/zarith.1.12
command ~/.opam/opam-init/hooks/ build make
exit-code 2
env-file ~/.opam/log/zarith-52113-b5f72c.env
output-file ~/.opam/log/zarith-52113-b5f72c.out
project.mak:150: depend: No such file or directory
(echo “let”; grep “version” META | head -1) >
ocamldep -native z.mli q.mli big_int_Z.mli > depend
File “”, line 2, characters 0-1:
2 | version = “1.12”
Error: Illegal character (\027)
make: *** [depend] Error 2


The command

opam list 

does not show ocaml-zarith as a package, and it is not found when I try

ocamlfind ocamlopt -o rho_z -linkpkg -package ocaml-zarith

and zarith is not found trying

ocamlfind ocamlopt -o rho_z -linkpkg -package zarith (note: this works on linux if zarith is installed)

So I am not clear how to use ocaml-zarith for zarith, since I cannot install zarith with opam.

Looks like grep on your system prepends the output with line numbers (that 2) by default and that’s tripping it up.


Interesting. I have a very similar system (Monterey 12.6, grep version grep (BSD grep, GNU compatible) 2.6.0-FreeBSD) and zarith installed fine for me. I suspect the OP aliased grep to another command.

That is strange indeed as the alias command is usually not respected in shell scripts, so OP must’ve shadowed grep in the PATH.

The problem is that the following are set:

export GREP_OPTIONS='--color=always'
export GREP_COLOR='1;35;40'

If I

export GREP_OPTIONS=‘–color=never’

an run

opam import zarith

the import is ok and my ocaml programs run with zarith

Still odd - those are GNU grep options, not the BSD grep which is normally first in the PATH on MacOS.


1 Like

Mine says it’s ‘GNU compatible’, maybe it does that.