This is a vague question, but I would be interested in tips on using libraries that are not in opam, or using a newer version of a library that hasn’t yet been upgraded in opam. I’m a little bit worried about this because at one point I managed to put a new version of a library in my opam directory tree and ended up with a confused configuration that didn’t work when I was able to upgrade the same package via opam. I resorted to deleting .opam and starting over from scratch.
I’m not asking about how to use git or make or oasis. Is there a standard way to take a compiled library from a git repo and install it in my opam tree? Or is this a bad idea? Or how does one tell utop or the compilers how to find something that’s not in the local opam system?
I feel as if I’m asking somewhat stupid questions. I feel as if I almost know enough, but have no idea what the next step is.
There is the
opam pin (see doc) command which is extremely useful for that purpose.
Most ocaml project actually make it possible to do
opam pin add -k git package_name https://some.git.repo
in order to have the development version installed (and managed) by opam.
opam pin add --dev package_name if you don’t need precise control on the commit you get.
Thanks @zozozo, @dbuenzli. That looks like some very useful and convenient opam magic.
I think I’ve misunderstood what
pin does until now. I thought that it was a way to have, in effect, different opam switches for different packages–so that for example I could have develop multiple packages, each of which automatically remembered which packages and versions it needed when I
cd to a particular development directory.
My understanding now is that that was just false. I can have different groups of packages by creating different switches, but I have to run
opam switch to change those for different development configurations, if that’s what I want.
opam pin is a way to take control of versioning and sources of packages, rather than letting opam decide what are the best versions of a package and its dependencies for a given version of OCaml. (Feel free to let me know if that’s not quite right.)
(Ah, now I see–local switches are what I thought
pin was doing.)