`cabal init` can fail with "Too many open files"

Open
#12,609 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
haskell
Domain
cli

Research direction

Start by locating the cabal init code that scans source directories and opens module files; the issue names no implementation file or test. Reproduce with a large source tree and a low file descriptor limit, then trace how files are opened during scanning. Done when cabal init handles many modules without exhausting open files.

Written by the indexing model from the issue text.

Description

needs triage type: bug

Describe the bug

cabal init fails with openFile: resource exhausted (Too many open files) when the source directory has many modules.

To Reproduce

$ gh repo clone cabalism/stack
Cloning into 'stack'...
...

$ cd stack

$ ulimit -Sn 1024

$ cabal init -n
Warning: this is a debug build of cabal-install with assertions enabled.
The name stack is already in use by another package on Hackage.
Warning: found module that doesn't match directory structure: Main
Warning: found module that doesn't match directory structure: implements
Warning: found module that doesn't match directory structure: does
Warning: found module that doesn't match directory structure: which
Warning: found module that doesn't match directory structure: which
Warning: found module that doesn't match directory structure: scans
Warning: found module that doesn't match directory structure: rather
/home/.../dev/src/cabalism/stack/src/Stack/Types/Cache.hs:
  openFile: resource exhausted (Too many open files)

HasCallStack backtrace:
  ioError, called at libraries/ghc-internal/src/GHC/Internal/Foreign/C/Error.hs:291:5 in
  ghc-internal:GHC.Internal.Foreign.C.Error

Expected behavior

The init command is able to cope with many modules.

Dominant language
Haskell
Stars
1.8k
Forks
766
Avg merge
5d 21h
Merged PRs (30d)
27

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from haskell/cabal

All issues in haskell/cabal

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.