Skip to content

Drop the remove scripts opam can do without - #51

Merged
toots merged 1 commit into
ocaml-cross:mainfrom
toots:drop-remove-scripts
Oct 9, 2026
Merged

toots merged 1 commit into
ocaml-cross:mainfrom
toots:drop-remove-scripts

Conversation

@toots

@toots toots commented Oct 9, 2026

Copy link
Copy Markdown
Member

This PR removes the remove: field from the 74 packages where it only deleted what the package had installed under the switch: the 73 ocamlfind -toolchain android remove <pkg> lines and cmdliner-android's rm -rf of its own library directory.

opam 2.6 cannot rebuild a package that has a remove field. The build directory is left without its sources, so the first build command that touches a source file fails. Any upgrade of a native dependency triggers it on a switch that already holds the package, which is how it showed up: ppxlib 0.39.0 was published, opam upgrade wanted to recompile ppx_deriving-android, and its build stopped at once.

sh -c ": > src/dune"
cannot create src/dune: Directory nonexistent

It reproduces without any cross-compilation, with a two-package repository where b depends on a, has a source archive and a remove field: install a.1 and b, publish a.2, run opam upgrade. opam 2.5.2 rebuilds b; 2.6.0 and 2.6.1 fail as above, whether the remove script succeeds or not, and whatever it runs (ocamlfind remove, rm -rf). Without the field, 2.6.1 rebuilds b, and opam remove b still deletes its files, since opam tracks what an install adds to the switch.

The ocamlfind remove lines were also failing by themselves on every package that installs a sub-directory (ocamlfind: …/lib/ppx_deriving/create: Is a directory), which opam reports as a warning and carries on from.

Four packages keep their script and will hit the same failure when opam 2.6 rebuilds them: ocaml-android (remove.sh), build-android-sysroot, build-gmp-android and build-libev-android. I left them alone because I could not check that opam's own tracking covers everything they install.

Not tested here: the cross builds themselves. The check was the reproduction above and opam lint on the edited files.

opam 2.6 cannot rebuild a package that has a `remove` field: the build
directory is left without its sources, so the first build command that
touches a source file fails. An upgrade of a native dependency is enough
to trigger it, as ppxlib 0.39.0 did for ppx_deriving-android:

    sh -c ": > src/dune"
    cannot create src/dune: Directory nonexistent

These scripts only removed files the package installed under the switch,
which opam tracks and removes by itself. `ocamlfind remove` also failed
on every package that installs a sub-directory.
@toots
toots merged commit 88c9904 into ocaml-cross:main Oct 9, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant