opam
opam copied to clipboard
Create opam root in `%LOCALAPPDATA%\opam` on Windows
If .opam is found in either %HOME% or %USERPROFILE% then use that, but roots are otherwise created in %LOCALAPPDATA%\opam.
This strategy is forwards-compatible with any switch to XDG (which would definitely introduce the situation where existing roots would be read from locations other than where a new root would be init'd). The location for Windows was discussed in #3766.
This is great; ordinary opam.exe will be able to read OPAMROOT from Diskuv's opam.exe.
The use of %HOME% also makes it compatible with opam-repository-mingw
LGTM
Looks like a tweak is needed to the runners. opam init is also incorrectly displaying ~\.opam as the install location.
Thanks for the review, @AltGr! I've hopefully fixed the CI - beforehand, OpamStd.Sys.home was falling to the default of .opam in the CWD which was a dreadful default for Windows, but actually correct for the runners (that's fixed by setting OPAMROOT)
There's an extra commit to be checked, though. I've altered the code so that you now get the correct display on Windows:
In normal operation, opam only alters files within ~\AppData\Local\opam.
but while there it was worth fixing #4992 as well. If the root is not the default, then you get this slightly different message:
In normal operation, opam only alters files within your opam root
(~\AppData\Local\opam by default; currently C:\Devel\opam-2\root).
We could possibly be more explicit about why the root has been overridden (there are three possibilities: --root, OPAMROOT or a legacy location - i.e. somewhere a root is read from but not written like %HOME%\.opam on Windows) but I expect that it's fine as it is.
Thanks a lot!