Install a local package with opam

Trying to install an home made library (called GenArrayIter) locally in order to reuse it within another of my projects.

I have put the stanza (public_name GenArrayIter) in the dune file of my library.

Then I do :

PS: H:\GenArrayIter> dune build
PS: H:\GenArrayIter> dune build ‘@install
PS: H:\GenArrayIter> opam install GenArrayIter
[ERROR] No package named GenArrayIter found.

I added single quotes to '@install' since I remember there is an issue with targets beginning with @ on windows machies…

I have red in dunes documentation that I should get an *.install file somewhere, which I don’t see.
I have an GenArrayIter.opam file at the root of my project…

Any hint ?

Does it work if instead you do opam install . --working-dir? The . means “package in this directory”, the --working-dir means “don’t try to be consistent across package dependencies by relying on git, just install what’s in the directory”.

Yes, it works this way. Why would I need to specify opam to install what is in this directory with a “.” and it would not work if I give the package name ? “.” is not in the default search path ?

There is no search path – opam relies on a database of repositories. Edit: that’s the impression I got.

I think you wouldn’t want a package manager inferring what packages to install just based on your current working directory: this makes package names context dependent and ambiguous and could lead to all kinds of confusing errors and security issues. E.g. you could shadow registered packages by accident.

1 Like