Hi @bentxt, thanks for trying this project, I help maintain this opam template.
About opam switches:
Local switches might be useful when you work with a lot of projects in the same computer. As the number of projects increases it might be harder to resolve the dependencies for all of them under a single switch, as opam only allows a single version of each package to be installed. But as you mention global switches are much more efficient in terms of storage.
It is very important to know which switch is selected before running any
opam command. To do so, one can run
opam switch. In the list of results, the active switch (local or global) will appear highlighted, and with an arrow on its left side. In this list, local switches name is the path to the switch in the file system, while global switches name is the version of the OCaml compiler they use.
About Melange and Dune:
One relevant thing to note is that the latest version of Melange is only compatible with Dune 3.8, which has not been released in the official opam repository yet. It seems it could be released very soon.
As Melange depends on this version of Dune, a new version for the
melange package will also be released a little bit after that.
I understand you want to build Melange using your opam “global” switch. To do this before the official releases happen you would need to use opam pin to install the unreleased version of both packages. So instead of doing
opam install <package> (which installs the officially released version), for now one has to use
opam pin add <package>.dev --dev-repo, e.g.:
opam remove melange # make sure no issues happen during the next command
opam pin add dune.dev --dev-repo # --dev-repo installs from latest commit in github
opam pin add melange.dev --dev-repo
As a side note, the way this “pinning” happens in melange-opam-template is by using opam
pin-depends field in the project opam file.
Finally, there is a short guide about Dune in the Melange docs site, which includes steps to build a simple project, either using OCaml or Reason syntax. Another section that you might find interesting is the package management one.
Hope this helps clarifying. This process will be much more straightforward in a few days / weeks.