Opam remove target

Recent .opam files may not include remove field because opam tracks installed files automatically. A few questions:

  1. Does this tracking depend on dune or should it work with any build system? How exactly opam gets the list of files that have been installed?
  2. If I have installed package how can I ask opam the list of installed files? How should I debug situations when opam remove packagename doesn’t remove installed files?
  1. opam is build-system agnostic. How does it get the list? Magic.
  2. opam show packagename --list-files is the command you’re looking for. As for your debugging problems, I think I’ll need more information on your exact problem.

From the .install file that e.g. dune writes, where it lists all things to be installed.

  1. opam scans the files in .opam/ twice, once before launching the installation target, and once after. It then finds out what has been modified by the package, and should therefore be undone when uninstalling.
    As a side note: this process is somewhat slow, as it turns out. Luckily, .install files do improve the situation: if the build system generates a .install file and has no custom install targets, then opam knows exactly what to install and uninstall, and can skip this step. This is not done currently (opam still scans the filesystem even if a .install is present), but I plan to implement this optimization in the near future.
    In any case, dune or not, .install or not, it should work, but relying on .install seems cleaner in the long run.

  2. The diff computed by opam is stored in .opam/<switch>/.opam-switch/install/<package>.changes. At the moment I’m not sure of the exact semantics of the information in the .changes files, but at least you should be able to look for your installed files.


Thanks. It was very helpful.