Open MSoegtropIMC opened 2 years ago
External dependencies are always checked: at (almost) each run, opam capture their state, and warn if currently conf installed packages have no more their corresponding external dependency installed.
The opam root is self sufficient, it is not aware on where it is. At most, only local switches have this path of the opam root. So if it is moved, opam itself can't know about it. Unless checking opam installed binaries, in a special mode, it is not possible to detect the machine arch move.
In device change, the best is to export all switches for switch in 'opam switch -s'; do opam switch export [options] --switch $switch; done
and reinstall them. (or try to, conf packages can be not available for the new device).
I believe it should be possible to record the machine architecture somewhere in the .opam
folder and warn the user if the machine architecture changed.
Regarding conf packages: would opam detect if e.g. libraries are there, say tested via pkg-config, but have a different architecture than the ocamlc in the current opam switch? I think this is the problem people are having. They move over .opam (or get it moved automatically) but reinstall Homebrew or Macports and then they end up with an x64 opam and ocamlc and a Homebrew or Macports which creates ARM libraries. The error messages resulting from that are not easy to understand - even for tutors in CS classes. So I think opam (or depext) should check if the architecture of Homebrew or Macports it uses matches the architecture of ocamlc.
I think in recent years this was hardly every a problem, but with the introduction of the M1 silicon, this is a real problem.
In the Coq Platform project (a sort of opam meta project) I get user reports with opam issues which essentially come from migration from an Intel Mac to an Apple M1 Mac. Under likely circumstances the .opam folder (part of the home folder) gets copied over from the Intel to the M1 Mac by account migration, which pretty much does havoc to the functionality of opam, especially if Homebrew or Macports are not migrated but setup new (usually the case because they are not part of home), so that one gets a mix of x64 and ARM binaries.
I would appreciate it if opam would check if the .opam folder was copied from a different machine (which means conf packages should be re-checked) and especially if it was copied from a machine with a different architecture - in which case opam should suggest to restart from scratch. I don't expect any automation in such a restart - just an information that users are doing something unintended, and maybe a link to a webpage explaining the situation.
For some users it might even make sense to keep the Intel .opam, but then one must take care that Homebrew / MacPorts are also Intel.