# mac os zarith problem

**URL:** <https://discuss.ocaml.org/t/mac-os-zarith-problem/10611>\
**Category:** Community\
**Tags:** mac, zarith, opam\
**Created:** [October 11, 2022, 4:40pm UTC](https://discuss.ocaml.org/t/mac-os-zarith-problem/10611 "2022-10-11T16:40:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doug\_Telford](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/doug_telford/32/3994_2.png) [@Doug\_Telford](https://discuss.ocaml.org/u/Doug_Telford)\
**Post date:** [October 11, 2022, 4:40pm UTC](https://discuss.ocaml.org/t/mac-os-zarith-problem/10611/1 "2022-10-11T16:40:39Z")

</div>

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 | [https://opam.ocaml.org#efe0e534](https://opam.ocaml.org#efe0e534)  
path ~/.opam/default/.opam-switch/build/zarith.1.12  
command ~/.opam/opam-init/hooks/sandbox.sh build make  
exit-code 2  
env-file ~/.opam/log/zarith-52113-b5f72c.env  
output-file ~/.opam/log/zarith-52113-b5f72c.out  
output  
project.mak:150: depend: No such file or directory  
(echo “let”; grep “version” META | head -1) \> zarith\_version.ml  
ocamldep -native zarith\_version.ml z.ml q.ml big\_int\_Z.ml z.mli q.mli big\_int\_Z.mli \> depend  
File “zarith\_version.ml”, 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 rho_z.ml

```

and zarith is not found trying

```
ocamlfind ocamlopt -o rho_z -linkpkg -package zarith rho_z.ml (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.

---

<div class="post-metadata">

**Author:** ![sim642](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/sim642/32/3597_2.png) [@sim642](https://discuss.ocaml.org/u/sim642)\
**Post date:** [October 11, 2022, 7:21pm UTC](https://discuss.ocaml.org/t/mac-os-zarith-problem/10611/2 "2022-10-11T19:21:20Z")

</div>

> [@Doug\_Telford](#):
>
> ```auto
> (echo “let”; grep “version” META | head -1) > zarith_version.ml
> ocamldep -native zarith_version.ml z.ml q.ml big_int_Z.ml z.mli q.mli big_int_Z.mli > depend
> File “zarith_version.ml”, line 2, characters 0-1:
> 2 | version = “1.12”
> ^
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [October 11, 2022, 11:28pm UTC](https://discuss.ocaml.org/t/mac-os-zarith-problem/10611/3 "2022-10-11T23:28:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Leonidas](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/leonidas/32/4039_2.png) [@Leonidas](https://discuss.ocaml.org/u/Leonidas)\
**Post date:** [October 12, 2022, 11:21am UTC](https://discuss.ocaml.org/t/mac-os-zarith-problem/10611/4 "2022-10-12T11:21:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dougT](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dougt/32/3998_2.png) [@dougT](https://discuss.ocaml.org/u/dougT)\
**Post date:** [October 12, 2022, 1:06pm UTC](https://discuss.ocaml.org/t/mac-os-zarith-problem/10611/5 "2022-10-12T13:06:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nobrowser](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nobrowser/32/2099_2.png) [@nobrowser](https://discuss.ocaml.org/u/nobrowser)\
**Post date:** [October 12, 2022, 10:03pm UTC](https://discuss.ocaml.org/t/mac-os-zarith-problem/10611/6 "2022-10-12T22:03:13Z")

</div>

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

–  
Ian

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [October 13, 2022, 2:00am UTC](https://discuss.ocaml.org/t/mac-os-zarith-problem/10611/7 "2022-10-13T02:00:17Z")

</div>

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