haskell / haskell/cabal

How to v2-install both library and executable

Open
#6,480 4 comments 0 reactions 0 assignees View on GitHub
cabal-install: cmd/install type: enhancement type: user-question
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
If I install a library followed by its executable, both seem to get rebuilt. This could be avoided if there were an easy way (e.g. `--exe --lib`) to build both in the first place, or if the command were smart enough to avoid the duplicate build.

**To Reproduce**
Steps to reproduce the behavior:

```
$ cabal v2-install --lib pandoc
$ cabal v2-install pandoc
```

**Expected behavior**
My original build (with `--lib`) already built the executable. It would be nice if it didn't have to be rebuilt, or failing that, if there were a way to explicitly request both to be installed.

**System information**
- Operating system: macOS 10.14
- `cabal` 3.0.0.0, `ghc` 8.8.1

**Additional context**
Sample output:
```
$ cabal v2-install --lib pandoc
Resolving dependencies...
[ ... ]
- pandoc-2.9.1.1 (lib) (requires download & build)
- pandoc-2.9.1.1 (exe:pandoc) (requires download & build)
[ ... ]
Installing pandoc-2.9.1.1 (exe:pandoc)
Completed pandoc-2.9.1.1 (exe:pandoc)
$ cabal v2-install pandoc
Resolving dependencies...
Build profile: -w ghc-8.8.1 -O1
In order, the following will be built (use -v for more details):
- process-1.6.7.0 (lib:process) (requires download & build)
- hsc2hs-0.68.6 (exe:hsc2hs) (requires build)
- network-3.1.1.1 (lib:network) (requires build)
- tls-1.5.3 (lib) (requires build)
- streaming-commons-0.2.1.2 (lib) (requires build)
- socks-0.6.1 (lib) (requires build)
- HTTP-4000.3.14 (lib) (requires build)
- http-client-0.6.4 (lib) (requires build)
- connection-0.3.1 (lib:connection) (requires build)
- http-client-tls-0.3.5.3 (lib) (requires build)
- pandoc-2.9.1.1 (lib) (requires build)
- pandoc-2.9.1.1 (exe:pandoc) (requires build)
[ ... ]
```

It's not quite as bad as a full rebuild, but it still requires extra time if you build the library and executable multiple times.

Contributor guide

Open the contributing guide

Research direction

Reproduce the two `cabal v2-install` commands shown in the issue and trace how the `--lib` and executable requests are handled. Done means requesting the library and executable together, or installing them sequentially, does not rebuild artifacts unnecessarily and provides a clear way to install both.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.