# Opam: system compiler vs. equivalent version

**URL:** <https://discuss.ocaml.org/t/opam-system-compiler-vs-equivalent-version/83>\
**Category:** Learning\
**Tags:** opam\
**Created:** [May 13, 2017, 8:51pm UTC](https://discuss.ocaml.org/t/opam-system-compiler-vs-equivalent-version/83 "2017-05-13T20:51:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mars0i](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mars0i/32/1058_2.png) [@mars0i](https://discuss.ocaml.org/u/mars0i)\
**Post date:** [May 13, 2017, 8:51pm UTC](https://discuss.ocaml.org/t/opam-system-compiler-vs-equivalent-version/83/1 "2017-05-13T20:51:59Z")

</div>

The questions below are not very deep or important, but I thought I’d use my mild confusion as the basis of the first post here.

I installed opam (using Homebrew on OS X) and it installed ocaml 4.04.1. I then installed a number of packages. Then I ran `opam switch 4.04.0` and installed the same packages for that compiler. I wasn’t sure how to switch back to the original compiler, and I like seeing my choices listed explicitly under .opam, anyway, so I ran `opam switch 4.04.1` and then installed the packages again. I believe that I now have all of my chosen packages compiled for 4.04.1 both under .opam/4.04.1 and .opam/system. (I’m guessing this about system, since `.opam/system/bin/ocaml -version` displays reports version 4.04.1.)

I don’t need to have the same packages in two places. Is there a reason to use the second installation of 4.04.1 rather than the original one labeled “system”, or vice versa? Can I remove the packages I installed at the beginning of this process by switching to system and then removing all of the packages? Or would it make more sense to simply remove the second 4.04.1 installation using `opam switch remove 4.04.1`?

---

<div class="post-metadata">

**Author:** ![dra27](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dra27/32/5294_2.png) [@dra27](https://discuss.ocaml.org/u/dra27)\
**Post date:** [May 13, 2017, 10:05pm UTC](https://discuss.ocaml.org/t/opam-system-compiler-vs-equivalent-version/83/2 "2017-05-13T22:05:51Z")

</div>

> [@mars0i](#):
>
> I installed opam (using Homebrew on OS X) and it installed ocaml 4.04.1.

Not quite - assuming a normal `opam init`, opam set-up a switch designed to _use_ your system compiler (it was probably considerably faster to set-up than the subsequent `opam switch` commands you ran?).

> [@](#):
>
> I then installed a number of packages. Then I ran opam switch 4.04.0 and installed the same packages for that compiler. I wasn’t sure how to switch back to the original compiler, and I like seeing my choices listed explicitly under .opam, anyway, so I ran opam switch 4.04.1 and then installed the packages again. I believe that I now have all of my chosen packages compiled for 4.04.1 both under .opam/4.04.1 and .opam/system. (I’m guessing this about system, since .opam/system/bin/ocaml -version displays reports version 4.04.1.)

You shouldn’t be needing to look at anything under .opam - `opam list` will show you what’s you installed in any given switch. It should be the case that `.opam/system/bin/ocaml` is a script installed as a result of installing the `ocamlfind` package (if it’s a binary, you have something strange going on with a system switch) - but again, you shouldn’t really need to be poking in the .opam directory.

> [@](#):
>
> I don’t need to have the same packages in two places. Is there a reason to use the second installation of 4.04.1 rather than the original one labeled “system”, or vice versa? Can I remove the packages I installed at the beginning of this process by switching to system and then removing all of the packages? Or would it make more sense to simply remove the second 4.04.1 installation using opam switch remove 4.04.1?

There can be occasional issues with using the system compiler - and indeed opam 1.x is not able to detect if you upgrade your system compiler very well (opam 2.0 improves this and will rebuild all the packages) but mostly you should be fine using it and, yes, you could just remove the 4.04.1 switch, as you say.

---

<div class="post-metadata">

**Author:** ![avsm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/avsm/32/6_2.png) [@avsm](https://discuss.ocaml.org/u/avsm)\
**Post date:** [May 13, 2017, 10:18pm UTC](https://discuss.ocaml.org/t/opam-system-compiler-vs-equivalent-version/83/3 "2017-05-13T22:18:20Z")

</div>

Some of your confusion comes from the `system` switch, which is a special-case. It exists so that you can use a pre-installed compiler (e.g. via Homebrew), but OPAM must deal with the fact that you might upgrade it externally (e.g. `brew update`). So, if you do an `opam switch 4.04.1`, you are compiling and installing a _new_ version of OCaml 4.04.1, even if your system switch is currently also pointing to OCaml 4.04.1.

You can verify what is actually active on your system by:

```
$ opam switch
-- -- 4.04.0 Official 4.04.0 release
4.04.1 C 4.04.1 Official 4.04.1 release
system I system System compiler (4.04.0)
# 237 more patched or experimental compilers, use '--all' to show

```

The “C” beside 4.04.1 indicates it is my currently active switch, and the “I” indicates an available but inactive switch.

For your needs, the system compiler is probably sufficient, and you would avoid another locally compiled version. To switch to it just do:

```
$ opam switch system
$ eval `opam config env`
$ opam switch remove 4.04.1
```

---

<div class="post-metadata">

**Author:** ![mars0i](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mars0i/32/1058_2.png) [@mars0i](https://discuss.ocaml.org/u/mars0i)\
**Post date:** [May 14, 2017, 4:55am UTC](https://discuss.ocaml.org/t/opam-system-compiler-vs-equivalent-version/83/4 "2017-05-14T04:55:55Z")

</div>

Thanks dra27, avsm. Both answers were very helpful.
