How to install a local package

i am trying to package one of my own project, in order to use it as a local library in another project. This is something I have already done but for some reason I have trouble doing it again today.

So I have this minimal library with one (irrelevant) ml file, a dune and a dune-project file. Here is the dune-project :

(lang dune 2.8)
(generate_opam_files true)

(package
 (name little)
 (synopsis "Little lib")
 (maintainers "dev-du-futur@mavie.fr")
 (description "Say hello")
 (depends
 (dune (> 2.8))
 )
)

As expected, dune build @install generates the following little.opam file :

# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "Little lib"
description: "Say hello"
depends: [
  "dune" {>= "2.8" & > "2.8"}
  "odoc" {with-doc}
]
build: [
  ["dune" "subst"] {dev}
  [
    "dune"
    "build"
    "-p"
    name
    "-j"
    jobs
    "@install"
    "@runtest" {with-test}
    "@doc" {with-doc}
  ]
]

And then when I do opam install little . (which I think is the correct way to achieve what I want) everything seems to be fine.
But then when I try to use my “library” in another project opam can’t find it :

dune init exec small --lib little 
dune exec ./small.exe

yields :

                ^^^^^^
Error: Library "little" not found.

Although if I do opam list :

# Packages matching: installed # Name # Installed # Synopsis 
...
 little ~dev pinned to version ~dev at file:///home/nico/code_thunks/opam_fuzzling/little-lib

little is present. I must be missing something obvious. Can anybody help me ?

At a glance, I would guess that your dune file contains a (library ...) stanza that’s missing (public_name little).

The package name (defined by dune-project and then used by opam) is a different concept from the ocamlfind library name (defined by dune and then used by other dune stanzas), and it’s necessary to state both even when they are spelled in the same way :slight_smile:

1 Like

Good catch, thank you :slight_smile: