haskell / alex

A lexical analyser generator for Haskell
https://hackage.haskell.org/package/alex
BSD 3-Clause "New" or "Revised" License
298 stars 82 forks source link

Alex build failing with missing filepath at preprocessing step #195

Closed solomon-b closed 4 months ago

solomon-b commented 3 years ago

I'm not sure if it is relevant but this is on Nixos.

➜ cabal build
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
 - alex-3.2.7 (exe:alex) (first run)
Preprocessing executable 'alex' for alex-3.2.7..
alex: /home/solomon/Development/haskell/alex/./data//AlexTemplate-ghc: openFile: does not exist (No such file or directory)

That filepath looks odd. Any ideas what might be going wrong?

TOTBWF commented 3 years ago

I can reproduce this with cabal build, however, stack build seems to work.

Note that this is on OSX, so it doesn't appear to be limited to nix.

andreasabel commented 2 years ago

I can confirm this problem on macOS Mojave.

Ericson2314 commented 2 years ago

Yes this is a very weird error. I think there is some logic in prior versions of alex to try to use newer templates? But those don't exist because we simplified the templating system.

Ericson2314 commented 2 years ago

BTW if you manually run alex on the file and delete the original Scan.hs, it will work. It is just when cabal invokes Alex that weird things happen!

Ericson2314 commented 2 years ago

Ah, this is because the autogenerated Paths_alex module allows alex_ env vars to override the data dirs. During the build those env vars are defined (at least with the latest Cabal), and thus we try to bootstrap feeding the old alex the new alex's templates! :facepalm:

More reason to finish https://github.com/simonmar/alex/pull/174, I suppose.

sgraf812 commented 4 months ago

Is this still a problem? I ran cabal build and cabal test successfully on master (3.5.1).

At any rate, I happy suffered from a similar error which can be traced back to Cabal; see https://github.com/haskell/happy/issues/274#issuecomment-2152649291.

andreasabel commented 4 months ago

Let's close this optimistically.