Skip to content

Regression in 3.10 cabal build: the extra-prog-path ends up first in the PATH, shadowing build-tools #9756

@andreasabel

Description

@andreasabel

My installdir is set to ~/.cabal/bin in my ~/.cabal/config file. I have alex-3.4.0.1 installed there.
I also have set extra-prog-path: ~/.cabal/bin set in my config.
I am trying to build this project which requires a newer alex:

cabal-version:  1.12
name:           cabal-bug-build-tool
version:        0
build-type:     Simple

library
  exposed-modules:  Foo.Lex
  default-language: Haskell2010
  build-depends:    base, array
  build-tools:      alex >=3.5.1.0

Foo/Lex.x contains some lexer definition to be processed with alex.

With cabal-3.10.2.1 and current master I am getting this error:

$ cabal build
...(building alex-3.5.1.0)...
Error: cabal-3.10.2.1: The program 'alex' version >=3.5.1.0 is required but
the version found at /Users/abel/.cabal/bin/alex is version 3.4.0.1

Building succeeds with cabal-3.8 and older.

Running with -v3 I see that the extra-prog-path ends up before the path for alex-3.5.1.0 in the PATH component of the environment.

("PATH","/Users/abel/.cabal/bin:/Users/abel/.cabal/store/ghc-9.8.2-b74f/lx-3.5.1.0-60b880d8/bin:/Users/abel/.cabal/bin:...

cabal exec instead calls the correct alex for this project:

$ cabal-master exec -- alex --version
Alex version 3.5.1.0, (c) 2003 Chris Dornan and Simon Marlow

I checked a bit the source of cabal and it seems that cabal exec does not receives the installdir, so it cannot interfere here.

The source files to reproduce it (on my system) are at https://github.com/andreasabel/cabal-bug-build-tool .

However, I could not reproduce the problem on the machines provided by GHA (see the workflow file for my attempt).
There, the PATH is correct:
> ("PATH","/home/runner/.cabal/store/ghc-9.8.2/alex-3.5.1.0-e-alex-075f98fe20ffc7a07799cfa46f51c24d5236956a51dccba7409f8f308610de2a/bin:/home/runner/.cabal/bin

Update: I could now reproduce it, supplying the extra-prog-path. It ends up first in the PATH:
https://github.com/andreasabel/cabal-bug-build-tool/actions/runs/8099486076/job/22135333052#step:10:1936

("PATH","/home/runner/.cabal/bin:/home/runner/.cabal/store/ghc-9.8.2/alex-3.5.1.0-e-alex-075f98fe20ffc7a07799cfa46f51c24d5236956a51dccba7409f8f308610de2a/bin:/home/runner/.cabal/bin:

CI proves that it is a regression in 3.10, as 3.8 succeeds there as well: https://github.com/andreasabel/cabal-bug-build-tool/actions/runs/8099613006

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions