Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to use this with with the hackage builder? #52

Closed
alaendle opened this issue Sep 18, 2023 · 11 comments
Closed

Question: How to use this with with the hackage builder? #52

alaendle opened this issue Sep 18, 2023 · 11 comments

Comments

@alaendle
Copy link

Sorry for misusing this issue here to ask for help how to use this tooling in conjunction with the hackage CI builder: I think I've followed the instructions and added to cabal file build-depends and build-tools-depends (to make things absolutely sure 😉 ).

  build-depends:       co-log-core
                       , markdown-unlit >= 0.5.0 && < 0.7
                       , text

  build-tool-depends:  markdown-unlit:markdown-unlit
  ghc-options:         -pgmL markdown-unlit

Nonetheless the builder complains with...

Failed to install co-log-0.6.0.1
Build log ( /home/builder/.cabal/logs/ghc-9.2.4/co-log-0.6.0.1-5zmvdGLdu6S2BNIMK9yuDU.log ):
cabal: Entering directory '/tmp/cabal-tmp-3681707/co-log-0.6.0.1'
Configuring co-log-0.6.0.1...
Preprocessing executable 'tutorial-intro' for co-log-0.6.0.1..
Building executable 'tutorial-intro' for co-log-0.6.0.1..
ghc: could not execute: markdown-unlit
cabal: Leaving directory '/tmp/cabal-tmp-3681707/co-log-0.6.0.1'
Error: cabal: Some packages failed to install:
co-log-0.6.0.1-5zmvdGLdu6S2BNIMK9yuDU failed during the building phase. The
exception was:
ExitFailure 1

See
https://hackage.haskell.org/package/co-log-0.6.0.1/co-log.cabal
and
https://hackage.haskell.org/package/co-log-0.6.0.1/reports/1

Thanks for your tool and I'm pretty sure this has nothing to do with your tool at all (and more with some hidden things the hackage CI is doing; also I couldn't reproduce it locally) - but maybe the problem is obvious to you?

@sol
Copy link
Owner

sol commented Sep 19, 2023

maybe the problem is obvious to you?

I don't see anything obvious. I suggest to open an issue for Hackage or Cabal.

@alaendle
Copy link
Author

Thanks; I try to further investigate/solve the underlying problem - and will post an update if I have news...

@alaendle
Copy link
Author

As it seems I rediscovered haskell/hackage-server#821 - as cabal documentation states tools are only added to the path for nix-style/v2 builds (https://cabal.readthedocs.io/en/3.10/cabal-package.html#pkg-field-build-tool-depends). However hackage still uses v1-builds 👎 ; so basically there is no way to solve this for now - case closed.

@sol
Copy link
Owner

sol commented Sep 19, 2023

You could probably still ask for markdown-unlit to be installed on Hackage, if it's important to you. I think most people just use it on CI, that might be the reason why its not available yet.

@sol
Copy link
Owner

sol commented Sep 19, 2023

@alaendle do this: Add markdown-unlit as a regular dependency. This should solve the Hackage issue.

@alaendle
Copy link
Author

@sol Maybe I've got this wrong, but that was my first thought too - and the change from v0.6.0.0 to v0.6.0.1 - co-log/co-log@deb2e47#diff-f5ec54a235408d1bb05b13a32989d74792b6c1c98f6391370e9a6e5f8205fb95 - and both versions (v0.6.0.0 - just referencing markdown-unlit in build-tool-depends; v0.6.0.1 - adding markdown-unlit to build-depends) expose the same problem.

@sol
Copy link
Owner

sol commented Sep 20, 2023

Ok, so this is odd, the relevant code is here: https://github.com/haskell/hackage-server/blob/30a4d8404dd9b70be0f00545d14a640b291107fc/exes/BuildClient.hs#L780

If I try cabal v1-install locally, that seems to work. The markdown-unlit executable is installed into the cabal bin dir (~/.cabal/bin or ~/.local/bin, depending on cabal version and where the cabal config is located).

build-depends: markdown-unlit should work with cabal v1-, at least it works for me locally.

Not sure why it doesn't work on Hackage. My best guess would be that the cabal bin dir is not on the PATH. Possibly this broke due to the XDG base dir transition, or it never worked, again not sure.

However, apparently tests are run with cabal v2-test: https://github.com/haskell/hackage-server/blob/30a4d8404dd9b70be0f00545d14a640b291107fc/exes/BuildClient.hs#L668

This explains why test suites that use hspec-discover build just fine on Hackage.

To summarize:

  • If you can convert your tutorials to a cabal test suites, then that's probably the easiest solution.
  • If cabal test suites are not an option, then I suggest open an issue for hackage-server. Again, build-depends: markdown-unlit should work with cabal v1-.

@alaendle
Copy link
Author

alaendle commented Sep 20, 2023

@sol Many thanks for sharing your thoughts! However converting the tutorials to test suites would be misleading in my opinion. Also I'm not sure if it is correct to expect cabal v1-install to really work here - I expect it is pure "coincidence" that you have the built markdown-unlit executable in your PATH. The server uses the option --prefix and so the executable is placed into (prefix)\bin as a result of the build-depends: markdown-unlit - but how should a next build step know about this location? - again, https://cabal.readthedocs.io/en/3.10/cabal-package.html#pkg-field-build-tool-depends states for old style builds "It’s up to the user to provide needed executables in this case under PATH.". To workaround this cabal v1 limitation the hackage builder could add the path upfront to PATH - that's all I can think of. So maybe I will go the easy way and add some build flags.

@sol
Copy link
Owner

sol commented Sep 20, 2023

Well, that's all I have to offer:

  • Either cabal v1- + build-depends: markdown-unlit + cabal build dir on the PATH, which probably means open a hackage-server issue
  • Or use cabal v2- which means test-suite as of now

Closing.

@sol sol closed this as completed Sep 20, 2023
@sol
Copy link
Owner

sol commented Sep 20, 2023

To workaround this cabal v1 limitation the hackage builder could add the path upfront to PATH

Yes, exactly, I think that's the right solution here.

@alaendle
Copy link
Author

Again many thanks to @sol who cares also about issues that doesn't directly have to do with his tools. And just for reference - in my case I just introduced a cabal flag and ensured that things dependent on markdown-unlit get build during CI on GitHub but not on hackage (co-log/co-log@06e54f8). Since the underlying causes are relatively old and I believe most people hope for "v2" hackage builds someday I'm not very optimistic that things improve hear in near-time. Also the problem isn't important enough for me to do anything about it myself at the moment (e.g. trying to write a PR that adds built executables to the PATH).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants