Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Doctest doesn't work if ghcup not used #30

Closed
newhoggy opened this issue Jan 28, 2021 · 12 comments
Closed

Doctest doesn't work if ghcup not used #30

newhoggy opened this issue Jan 28, 2021 · 12 comments
Labels
re: cache Concerning caching

Comments

@newhoggy
Copy link
Contributor

newhoggy commented Jan 28, 2021

When running doctest in Github Actions, if GHC is not installed via ghcup (for example it was already installed in the virtual environment) then the doctest fails in this manner:

doctest: /home/runner/.ghcup/ghc/8.10.3/bin/ghc-8.10.3: getPermissions:getFileStatus: does not exist (No such file or directory)

https://github.com/haskell-works/hw-aeson/pull/46/checks?check_run_id=1780850470

For some reason doctest expects that ghc is found under ghcup, when it is actually elsewhere.

@hazelweakly
Copy link
Collaborator

Out of curiosity, what does the $PATH and contents of the .ghc.environment.x86_64-linux-8.10.3 file look like? This is a new one for me...

@quasicomputational
Copy link

I don't have a good understanding of what the Haskell stuff for Github Actions actually does to set the environment up (but I suspect I'm going to have to learn it quite soon) - does it use ghcup? I am guessing there are two GHCs in play and doctest is getting confused about which one to use.

I see from the log that the build is downloading a large chunk of pre-built packages into .cabal. This might be it: doctest uses ghc-paths to know where to find GHC, which does some build-time magic. If the cached pre-built packages have GHC living somewhere else to where GHC lives on the builder, I wouldn't be surprised if that causes problems like this - though I am slightly surprised that this issue's only turning up now, because this sort of pattern isn't uncommon.

@hazelweakly
Copy link
Collaborator

Thanks to a hint from quasicomputational, my best guess is this:

  1. github actions uses hvr's PPA on linux, falling back to ghcup if it didn't work.
  2. This line -rwxr-xr-x 1 runner docker 59842504 Sep 29 in the logs suggests that the cache hit is from approximately september 29? But either way, there was a period in time where the runners had not been updated to use the latest version of hvr's PPA, but ghcup was using GHC 8.10.3, so it was possible to install GHC 8.10.3 through ghcup before the PPA
  3. This pipeline was ran during that time and thus had cached artifacts that were built with ghcup's GHC, and then later had cached artifacts built with the PPA's GHC
  4. Somehow this broke things??

So it requires a somewhat ridiculous chain of events, but it's not impossible. If that's the case, deleting the cache should fix the issue. Unfortunately I haven't the slightest idea how one might fix this except somehow by possibly either changing the caching strategy of cabal-cache, or by having doctests use alternative methods of finding GHC?

@quasicomputational
Copy link

Right. If the theory's correct, this is really the collision of two issues:

  1. doctest is not friendly to cross-compilation. I think that this might be for reasons, but I've forgotten what they were. I'll open an aspirational issue about that, but it might never get resolved.
  2. The caching strategy is fragile for packages that don't cross-compile well. This looks more tractable in practice: just excluding ghc-paths and all its dependencies from the cache could be a significant improvement.

@newhoggy
Copy link
Contributor Author

You are right. Clearing the cache solves the problem.

@newhoggy
Copy link
Contributor Author

newhoggy commented Feb 19, 2021

I'm keen on package maintainers avoiding things that make for non-relocatable cabal store packages where-ever possible.

@harendra-kumar
Copy link

It seems it is not very uncommon. I have hit the same issue: https://github.com/composewell/streamly/pull/1100/checks?check_run_id=2819329899 . I reached the same conclusion that it might be coming from the cache, tried bumping the cache version, but it did not help. I have to confirm that though, maybe the cache somehow did not get cleared.

@harendra-kumar
Copy link

It worked when I changed the cabal version 3.4 to 3.2.

@harendra-kumar
Copy link

It worked with clearing the cache too, earlier I made a mistake so the cache was not cleared.

@neongreen
Copy link

Possibly related workaround: haskell-servant/servant@164bfe9

@sol
Copy link
Member

sol commented Nov 15, 2021

The ghc-paths package provides paths to GHC's package database and ghc itself. You can't compile ghc-paths with a ghc from one place and then later use it with a ghc from an other place (place == path of the ghc executable). If you do that, you are on your own. That's not doctest specific.

@andreasabel
Copy link
Member

This issue has been resolved, judging from the conversation.

@andreasabel andreasabel closed this as not planned Won't fix, can't repro, duplicate, stale Dec 28, 2022
@andreasabel andreasabel added the re: cache Concerning caching label Dec 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
re: cache Concerning caching
Projects
None yet
Development

No branches or pull requests

7 participants