Skip to content

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

Open

Description

@gromakovsky

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?

Activity

  1. added a commit that references this issue on May 19, 2020
  2. changed the title [-]There seems to be no way to use build tools in Hackage packages[/-] [+]There seems to be no way to use build tools in Hackage packages (need v2-build)[/+] on Jun 7, 2021
  3. gbaz commented on Jun 7, 2021

    @gbaz
    Contributor

    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: haskell/cabal#6811
    haskell/cabal#6851
    haskell/cabal#6938
    haskell/cabal#6876

  4. added a commit that references this issue on Jul 26, 2021
  5. sol commented on Sep 19, 2023

    @sol
    Member

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

  6. domenkozar commented on Feb 9, 2024

    @domenkozar

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

    workaround

  7. added
    re: build-tools
    on Mar 18, 2024
  8. bgamari commented on May 12, 2025

    @bgamari
    Contributor

    This is blocked on #1393.

  9. andreasabel commented on May 13, 2025

    @andreasabel
    Member

    @sol wrote:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: doc builderre: build-tools

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions