haskell / haskell/cabal

cabal: Error: Could not find module: "Added_prepossor_module_name" with any suffix

Open
#6,124 2 comments 0 reactions 0 assignees View on GitHub
cabal-install: cmd/sdist Cabal: stanza/custom-setup
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
`% cabal v2-sdist`
`cabal: Error: Could not find module: SciDbAFL with any suffix:`
`["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the`
`module is autogenerated it should be added to 'autogen-modules'.`

I have added the preprocessor `bnfc` to a custom `Setup`. The file `SciDbAFL.cf` is not found.

**To Reproduce**
`% cabal v2-sdist`
###
Here is a snip of the custom `Setup`:

`main :: IO ()`
`main = defaultMainWithHooks simpleUserHooks{hookedPreProcessors =`
`("cf",ppBnfc):knownSuffixHandlers}`

The input file to `bnfc` is `SciDbAFL.cf` and the appropriate snip of my `scidb-hquery.cabal` is

`other-modules:`
`SciDbAFL`
`AbsSciDbAFL`
`ErrM`
`LexSciDbAFL`
`ParSciDbAFL`
`PrintSciDbAFL`

`autogen-modules:`
`AbsSciDbAFL`
`ErrM`
`LexSciDbAFL`
`ParSciDbAFL`
`PrintSciDbAFL`

**Where to find the problem**
In the file `cabal-install-2.4.1.0/Distribution/Client/CmdSdist.hs`, in the the function `packageToSdist`, the following line of code _only_ uses `knownSuffixHandlers`:

`listPackageSources verbosity (flattenPackageDescription $ packageDescription pkg) knownSuffixHandlers`

For example, as a test, if I hard code

listPackageSources verbosity (flattenPackageDescription $ packageDescription pkg) (("cf",undefined):knownSuffixHandlers)

then my hacked `cabal v2-sdist` works.

**Expected behavior**
I expect `cabal v2-sdist` to not only use the the `knownSuffixHandlers` but also those in `hookedPreProcessors`.

**Work around**
I have an (ugly) work around. One just adds `SciDbAFL` to `autogen-modules`, which it is of course not, and one adds it also to

`extra-source-files:`
`src/SciDbAFL.cf`

As I understand it, this respects what nix wishes to accomplish.

**System informataion**
- Operating system: Ubuntu 16.04.6 LTS (Xenial Xerus)
- $ cabal --version
cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library
- $ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5

**Additional context**
The issue was discovered with a cabal package that I am creating that uses `bnfc --haskell` via the `hookedPreProcessors` record.

Contributor guide

Open the contributing guide

Research direction

Start in cabal-install-2.4.1.0/Distribution/Client/CmdSdist.hs at packageToSdist, where listPackageSources is called with knownSuffixHandlers. Trace how hookedPreProcessors is represented and used, then make v2-sdist include custom preprocessor handlers so generated sources such as SciDbAFL are found without the autogen-modules workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.