[windows] Allow to (silently) upgrade shimgens
Currently we use https://github.com/71/scoop-better-shimexe on windows to emulate symlinks, see https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/d9d196439ff1866c83e7a663dfa064674aff4748/lib/GHCup/Utils.hs#L971-1077
It is downloaded from here: https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/d9d196439ff1866c83e7a663dfa064674aff4748/ghcup-0.0.5.yaml#L3
Due to upstream bugs, the shimgen exe had to be rebuilt already, see https://github.com/71/scoop-better-shimexe/pull/12
The current ghcup code doesn't update previously installed shimgens. You'd have to reinstall a GHC version to get the new shimgen exe. This needs to be improved.
It's a little unclear where we'd want this logic since it's possibly expensive. We'd very likely want this logic in ensureGlobalTools
. However it's currently run on any subcommand: https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/d9d196439ff1866c83e7a663dfa064674aff4748/app/ghcup/Main.hs#L1153
It might be necessary to invoke this function in a smarter on-demand way without doing unnecessary calls. Currently the following commands may require shimgen exe: install
, compile
, set
, rm
. However, this might quickly become difficult to maintain code, in case future commands are added.
Another question is how to actually detect an upgrade? Getting the hash of each shimgen in the bin folder might be an expensive operation. Unconditionally copying the shimgens as well, but maybe more robust? Maybe we should store the shimgen exe with version suffix in the cache folder and then we could simply compare with pre-existing shimgen exe (and if none is there, force an upgrade anyway).