Cabal: 'new-run' seems to not work when there's both an exe and a lib in a package

Created on 18 Jul 2017  路  7Comments  路  Source: haskell/cabal

To reproduce:

  • Create a package with both a library and an executable in it.
  • Try to build and run it with a command like cabal new-run exe-name -- arg1 arg2.

This will fail with an error message similar to the following:

$ cabal new-run consumers-example -- args
Up to date
[...]/dist-newstyle/build/x86_64-linux/ghc-8.0.2/consumers-2.0.1/build/consumers-example/consumers-example: rawSystem: runInteractiveProcess: exec: does not exist (No such file or directory)

The problem is that the exe is actually under ./dist-newstyle/build/x86_64-linux/ghc-8.0.2/consumers-2.0.1/c/consumers-example/build/consumers-example/consumers-example (note the /c/consumers-example bit) in this configuration, so new-run predictably fails to find it.

nix-local-build bug

All 7 comments

I'm surprised this bug could have happened. Could it be extractMatchingElaboratedConfiguredPackages is not returning the elaborated component for the executable, but the library instead? I don't see any obvious bugs in the code.

4607 also fixes this. I'll add a test.

EDIT: added with 999d0f277

I've just encountered this issue. The upstream version of cabal works, but the one on Hackage doesn't. Maybe it's time for a release?

@int-index
This seems to be part of https://github.com/haskell/cabal/milestone/45, due by the end of september

Is it me is cabal new-run entirely out of its depths now with Cabal v2.0.1? With both a single executable _and_ an exe and lib together, I'm getting:

cabal new-run exe:foo -- a
cabal: Unknown target 'a'.
There is no component 'a'.
The project has no package 'a'.

A plain cabal new-run returns:

Up to date

cabal new-build and a manual invocation of the exe in dist-newstyle work fine.

Unless I'm mistaken with the 3 and 4 digit version numbers... cabal --version is returning v2.0.0.1, not v2.0.1 as https://github.com/haskell/cabal/milestone/45 lists...

new-run didn't make it into 2.0, try with HEAD or 2.2, which will be out next month.

Was this page helpful?
0 / 5 - 0 ratings