hackage-server icon indicating copy to clipboard operation
hackage-server copied to clipboard

There seems to be no way to use build tools in Hackage packages (need v2-build)

Open gromakovsky opened this issue 6 years ago • 5 comments

I want to upload a package that uses a custom build tool, namely autoexporter. However, apparently there is no way to do it so that the package will be successfully built by Hackage. There are two relevant things that can be specified in .cabal files: build-tools and build-tool-depends.

I don't know which exact Cabal version is used by Hackage. However, if Cabal version is less than 2, only build-tools is available. Its documentation says the following:

A list of Haskell programs needed to build this component. Each may be followed by an optional version bound. Confusingly, each program in the list either refer to one of three things:

        Another executables in the same package (supported since Cabal 1.12)
        Tool name contained in Cabal’s hard-coded set of common tools
        A pre-built executable that should already be on the PATH (supported since Cabal 2.0)

In my case autoexporter is not in my package and is not a hard-coded tool. And the third option from the list above doesn't work before Cabal 2.0.

Now let's assume that Cabal ≥ 2.0 is used, which is more likely. If we use the old build-tools option, we can consider the third case described there:

A pre-built executable that should already be on the PATH (supported since Cabal 2.0)

I've tried to use it, but build failed: https://hackage.haskell.org/package/morley-0.1.0.3/reports/1 https://hackage.haskell.org/package/morley-0.1.0.3/morley.cabal

So probably autoexporter is not on the PATH, which is not surprising.

I've also tried using build-tool-depends. Unfortunately, it doesn't work either: https://hackage.haskell.org/package/morley-0.1.0.2/reports/1 https://hackage.haskell.org/package/morley-0.1.0.2/morley.cabal

The documentation says the following:

Cabal tries to make sure that all specified programs are atomically built and prepended on the $PATH shell variable before building the component in question, but can only do so for Nix-style builds. Specifically:

    For Nix-style local builds, both internal and external dependencies.
    For old-style builds, only for internal dependencies [1]. It’s up to the user to provide needed executables in this case under $PATH.

AFAIU, Hackage uses old-style builds, I think so because there is a warning at the beginning of build report:

Warning: The install command is a part of the legacy v1 style of cabal usage.

So this build-tool-depends seems to work only for internal dependencies.

So I have a question: is it possible to use an external build tool so that Hackage build passes? Specifically:

  1. Maybe it's possible to forcefully use new-install instead of install?
  2. Maybe it's possible to somehow tell Hackage to put autoexporter (or any other build tool which is not hardcoded) into $PATH?

gromakovsky avatar Mar 30 '19 13:03 gromakovsky

We tried to use v2 build in the latest gsoc and I think the obstacle we ran into was that the test and coverage flags didn't all work nicely with it.

cf: https://github.com/haskell/cabal/issues/6811 https://github.com/haskell/cabal/issues/6851 https://github.com/haskell/cabal/issues/6938 https://github.com/haskell/cabal/issues/6876

gbaz avatar Jun 07 '21 01:06 gbaz

@gbaz what's the procedure for getting build tools installed globally on Hackage? @alaendle wanted to use markdown-unlit. https://github.com/sol/markdown-unlit/issues/52

sol avatar Sep 19 '23 17:09 sol

This would be incredibly useful for those using markdown-unlit, as it makes sure that README code actually works.

workaround

domenkozar avatar Feb 09 '24 11:02 domenkozar