haskell / haskell/cabal

The version of `alex` is not being correctly parsed

Open
#8,876 5 comments 0 reactions 0 assignees View on GitHub
attention: pr-welcome can-workaround type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**

When running tests, Cabal is unable to parse the Alex version installed:
```
Run cabal test all \
Resolving dependencies...
Build profile: -w ghc-9.2.4 -O1
In order, the following will be built (use -v for more details):
- vehicle-syntax-0.1.0 (lib:vehicle-syntax) (configuration changed)
- vehicle-0.1.0 (lib) (configuration changed)
- vehicle-0.1.0 (lib:vehicle-unit-tests-common) (configuration changed)
- vehicle-0.1.0 (lib:vehicle-golden-tests-common) (configuration changed)
- vehicle-0.1.0 (exe:vehicle) (configuration changed)
- vehicle-0.1.0 (test:vehicle-unit-tests) (configuration changed)
- vehicle-0.1.0 (test:vehicle-golden-tests) (configuration changed)
[1 of 1] Compiling Main ( /home/runner/work/vehicle/vehicle/dist-newstyle/build/x86_64-linux/ghc-9.2.4/vehicle-syntax-0.1.0/setup/setup.hs, /home/runner/work/vehicle/vehicle/dist-newstyle/build/x86_64-linux/ghc-9.2.4/vehicle-syntax-0.1.0/setup/Main.o )
Linking /home/runner/work/vehicle/vehicle/dist-newstyle/build/x86_64-linux/ghc-9.2.4/vehicle-syntax-0.1.0/setup/setup ...
Create directory for generated modules: autogen
Configuring vehicle-syntax-0.1.0...
setup: The program 'alex' version >=3 is required but the version of
/home/runner/.cabal/store/ghc-9.2.4/alex-3.2.7.1-e-alex-74292c840d46e203e846[16](https://github.com/vehicle-lang/vehicle/actions/runs/4498380696/jobs/7914938112#step:4:17)7e7ae[20](https://github.com/vehicle-lang/vehicle/actions/runs/4498380696/jobs/7914938112#step:4:21)1e465952b30efa86f91f8eef0e8478e6cc0/bin/alex
could not be determined.

Error: cabal: Failed to build vehicle-syntax-0.1.0 (which is required by
test:vehicle-unit-tests from vehicle-0.1.0 and test:vehicle-golden-tests from
vehicle-0.1.0). The failure occurred during the configure step.
```

Relevant part of the `.cabal` file:
```
build-tool-depends:
, alex:alex ==3.2.7.1
, BNFC:bnfc >=2.9.4
, happy:happy >=1.19
```

The error appears to be this one:

https://github.com/haskell/cabal/blob/00a2351789a460700a2567eb5ecc42cca0af913f/Cabal/src/Distribution/Simple/Program/Db.hs#L489-L492

and originates from here:

https://github.com/haskell/cabal/blob/00a2351789a460700a2567eb5ecc42cca0af913f/Cabal/src/Distribution/Simple/Program/Builtin.hs#L239-L247

**To Reproduce**

Shows up regularly on [our](https://github.com/vehicle-lang/vehicle) CI (e.g. [here](https://github.com/vehicle-lang/vehicle/actions/runs/4498380696/jobs/7914938112)). Appears to be non-deterministic to begin with, but once it happens once, happens every time subsequently until we clear the Github caches.

**Expected behavior**

Cabal should be able to parse the Alex version.

**System information**
- Operating system: Linux
- GHC: GHC 9.2.4
- Cabal: 3.8.1.0

**Additional context**

Might be a problem with Alex instead, but unsure?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.