Monorepo management for opam overlays
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

monopam: filter local-private libs from missing-dep detection

A '(library (name X))' stanza without '(public_name)' compiles to a
workspace-private archive — sibling stanzas can '(libraries X)' it,
but no opam package installs it. The lint was treating such refs as
external opam deps, so claude.opam ended up declaring 'json_utils'
(used only by ocaml-claude/examples/) as a runtime dep, leaking out
to https://tangled.org/gazagnaire.org/opam-overlay.

Walk every dune file in the subtree via Dune.File.private_library_names
(nox-dune) and collect those names. dune_needed_packages and
dune_packages_by_owner now resolve such refs to None and skip them
when computing the missing-dep set. The Unused detector still flags
them: if an opam file already declares one, the regen drops it.

+33 -4
+1
dune-project
··· 36 36 requests 37 37 (ptime (>= 1.0.0)) 38 38 (nox-sexp (>= 0.1.0)) 39 + (nox-dune (>= 0.1.0)) 39 40 (nox-tty (>= 0.1.0)) 40 41 (nox-tty-eio (>= 0.1.0)) 41 42 (retry (>= 0.1.0))
+5
lib/dune
··· 17 17 nox-json 18 18 ptime 19 19 nox-sexp 20 + nox-dune 20 21 nox-meta 21 22 nox-meta.bytesrw 22 23 nox-git ··· 26 27 nox-tty 27 28 nox-tty-eio 28 29 unix)) 30 + 31 + (mdx 32 + (files remote_cache.mli) 33 + (libraries monopam uri))
+26 -4
lib/lint.ml
··· 288 288 | exception Eio.Io _ -> []) 289 289 entries 290 290 291 + (** Names of [(library (name X))] stanzas in [subtree_path] that have no 292 + [(public_name ...)]. Sibling [(libraries X)] refs to such names link against 293 + a workspace-private archive, not an opam package, so they must not surface 294 + as a dep. Walks every [dune] file under the subtree via 295 + {!Dune.File.private_library_names}. *) 296 + let local_private_libs ~fs subtree_path = 297 + dune_files_in ~fs subtree_path 298 + |> List.concat_map (fun df -> 299 + match load_file fs df with 300 + | None -> [] 301 + | Some content -> 302 + parse_sexps content |> Dune.File.parse 303 + |> Dune.File.private_library_names) 304 + |> String_set.of_list 305 + 291 306 (** Collect all packages referenced via [(libraries ...)] in any dune file in a 292 307 subtree. This covers executable and test deps not captured by META. *) 293 308 let dune_needed_packages ~fs ~index subtree_path = 294 309 let dune_files = dune_files_in ~fs subtree_path in 310 + let private_libs = local_private_libs ~fs subtree_path in 295 311 List.concat_map 296 312 (fun df -> 297 313 match load_file fs df with ··· 299 315 | Some content -> extract_used_libs (parse_sexps content)) 300 316 dune_files 301 317 |> List.filter_map (fun lib -> 302 - if is_builtin lib then None else Some (lib_to_package index lib)) 318 + if is_builtin lib || String_set.mem lib private_libs then None 319 + else Some (lib_to_package index lib)) 303 320 |> String_set.of_list 304 321 305 322 (** Owning opam package for a single dune stanza. Prefers an explicit ··· 382 399 | _ -> ()) 383 400 | _ -> ()) 384 401 stanzas; 402 + let local_private = local_private_libs ~fs subtree_path in 385 403 let resolve lib = 386 404 match Hashtbl.find_opt internal_to_public lib with 387 - | Some pub -> pub 388 - | None -> lib_to_package index lib 405 + | Some pub -> Some pub 406 + | None -> 407 + if String_set.mem lib local_private then None 408 + else Some (lib_to_package index lib) 389 409 in 390 410 let tbl = Hashtbl.create 16 in 391 411 let add owner pkg = ··· 397 417 in 398 418 let attribute owner fields = 399 419 List.iter 400 - (fun lib -> if not (is_builtin lib) then add owner (resolve lib)) 420 + (fun lib -> 421 + if not (is_builtin lib) then 422 + match resolve lib with Some pkg -> add owner pkg | None -> ()) 401 423 (libs_of_fields fields) 402 424 in 403 425 List.iter
+1
monopam.opam
··· 32 32 "requests" 33 33 "ptime" {>= "1.0.0"} 34 34 "nox-sexp" {>= "0.1.0"} 35 + "nox-dune" {>= "0.1.0"} 35 36 "nox-tty" {>= "0.1.0"} 36 37 "nox-tty-eio" {>= "0.1.0"} 37 38 "retry" {>= "0.1.0"}