[SOLVED] Cabal v2-run and fake-package-0, infinite loop?

I am using GHC version 8.6.5, and cabal-install version on Ubuntu 20.04.4 LTS.

If I simply do “cabal v2-run”, it seems to work fine:

ppelleti@midnight-star:~/prg/hs/font-convert$ cabal v2-run
Resolving dependencies...
Up to date
Usage: font-convert src dest

However, my program needs arguments to work, so I tried passing the arguments to v2-run, after a --. This resulted in Cabal building some sort of “fake-package-0” that it didn’t build when I wasn’t passing arguments.

ppelleti@midnight-star:~/prg/hs/font-convert$ cabal v2-run -- ~/misc/unscii/unscii-8-mcr.hex unscii-8-mcr.png
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - fake-package-0 (exe:script) (configuration changed)
Configuring executable 'script' for fake-package-0..
Preprocessing executable 'script' for fake-package-0..
Building executable 'script' for fake-package-0..
[1 of 1] Compiling Main             ( Main.hs, /home/ppelleti/prg/hs/font-convert/dist-newstyle/build/x86_64-linux/ghc-8.6.5/fake-package-0/x/script/build/script/script-tmp/Main.o )

Unfortunately, this “Compiling Main” step never terminated. I looked at top and GHC was using 100% of my CPU. Hitting Control-C returned me to my prompt, but did not terminate the GHC that was using 100% CPU. Using plain kill on the GHC PID didn’t stop it either. I had to kill -9 to get rid of it.

Any idea what’s going on? I’m curious what “fake-package-0” is all about, and I’m especially curious why it sucks up all the CPU and doesn’t terminate.

I don’t know exactly what happened with your build, but I have noticed before that you need to add the name of your executable if you want to add extra arguments with --, so probably

cabal v2-run font-convert -- ~/misc...

Also, you might want to update your cabal-install and maybe GHC too for good measure. I do recommend using GHCup instead of Ubuntu’s packages.

1 Like

Thanks, that fixed the problem! I swear that with Cabal v1, that wasn’t necessary, though. As long as you only had one executable in your cabal file, it would pick that one executable if you didn’t specify a name before the --. It hadn’t occurred to me that v2 would be different in that respect.

The relevant ticket is https://github.com/haskell/cabal/issues/7247

If the project has a single package cabal run all and cabal run . (if the package is in the working directory) should work too

1 Like

The cabal run script.hs feature got triggered. This is definitely a point in favour of changing the current behaviour