Ghc-mod fails repeatedly when only a test suite entry in cabal


#1

if the cabal file contains only a test-suite entry ghc-mod throws the following error for each build command:

the workaround is simple - add a dummy executable section.

second thought: the error could have been caused by missing the stack solver update the stack-yaml and an error produced by cabal missing a dependency. perhaps only a better error reporting is sufficient.

[Enter steps to reproduce:]

1. ...
2. ...

**Atom**: 1.14.3 x64
**Electron**: 1.3.13
**OS**: Debian GNU/Linux
**Thrown From**: [haskell-ghc-mod](https://github.com/atom-haskell/haskell-ghc-mod) package 1.19.9


### Stack Trace

Haskell-ghc-mod: ghc-mod command check failed with error Error

```
At caps: {"version":[5,7,0,0],"fileMap":true,"quoteArgs":true,"optparse":true,"typeConstraints":true,"browseParents":true,"interactiveCaseSplit":true,"importedFrom":false}
URI: /home/frank/Workspace8/testExample/src/ExampleTesting.hs
Args: --
message: Command failed: /home/frank/.local/bin/ghc-mod check /home/frank/Workspace8/testExample/src/ExampleTesting.hs --
Warning: 'dist/setup-config' exists, ignoring Stack project
cabal-helper-0.7.3.0-Cabal-1.24.2.0: user error (No libraries, executables, tests, or benchmarks are enabled for package testExample-0.0.1.)
ghc-mod: readCreateProcess: /home/frank/.stack/snapshots/x86_64-linux-nopie/lts-8.1/8.0.2/libexec/x86_64-linux-ghc-8.0.2/cabal-helper-0.7.3.0/cabal-helper-wrapper "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" "/home/frank/Workspace8/testExample" "/home/frank/Workspace8/testExample/dist" "write-autogen-files" (exit 1): failed

log:
-23.321s: "Running /home/frank/.local/bin/ghc-mod lint,/home/frank/Workspace8/testExample/src/ExampleTesting.hs,-- with opts = ",{"cwd":"/home/frank/Workspace8/testExample","env":{"ATOM_HOME":"/home/frank/.atom","NODE_PATH":"/usr/share/atom/resources/app.asar/exports","NODE_ENV":"production","LS_COLORS":"","XDG_MENU_PREFIX":"xfce-","LANG":"en_US.utf8","DISPLAY":":0.0","XDG_VTNR":"7","SSH_AUTH_SOCK":"/tmp/ssh-qNxA1dMr81c6/agent.2231","CLASSPATH":"pikes-tintop-1.0-SNAPSHOT-jar-with-dependencies.jar:Semafor-3.0-alpha-04.jar:models/stanford-corenlp-3.5.2-models.jar","GLADE_CATALOG_PATH":":","XDG_SESSION_ID":"4","XDG_GREETER_DATA_DIR":"/var/lib/lightdm/data/frank","USER":"frank","GLADE_MODULE_PATH":":","DESKTOP_SESSION":"lightdm-xsession","PWD":"/home/frank","HOME":"/home/frank","SSH_AGENT_PID":"2269","QT_ACCESSIBILITY":"1","XDG_SESSION_TYPE":"x11","XDG_DATA_DIRS":"/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share","XDG_SESSION_DESKTOP":"lightdm-xsession","GLADE_PIXMAP_PATH":":","DESKTOP_STARTUP_ID":"wrapper-1.0/|usr|share|atom|atom/2337-2-santafe_TIME7024650","GTK_MODULES":"gail:atk-bridge","SHELL":"/bin/bash","XDG_SEAT_PATH":"/org/freedesktop/DisplayManager/Seat0","XDG_CURRENT_DESKTOP":"XFCE","QT_LINUX_ACCESSIBILITY_ALWAYS_ON":"1","SHLVL":"1","XDG_SEAT":"seat0","LANGUAGE":"en_US:en","GDMSESSION":"lightdm-xsession","LOGNAME":"frank","DBUS_SESSION_BUS_ADDRESS":"unix:path=/run/user/1010/bus","XDG_RUNTIME_DIR":"/run/user/1010","XAUTHORITY":"/home/frank/.Xauthority","XDG_SESSION_PATH":"/org/freedesktop/DisplayManager/Session0","XDG_CONFIG_DIRS":"/etc/xdg","GOOGLE_API_KEY":"AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q","PATH":"/home/frank/.stack/global-project/.stack-work/install/x86_64-linux-nopie/lts-8.8/8.0.2/bin:/home/frank/.stack/snapshots/x86_64-linux-nopie/lts-8.8/8.0.2/bin:/home/frank/.stack/programs/x86_64-linux/ghc-nopie-8.0.2/bin:/home/frank/.local/bin:/home/frank/.local/bin/:/home/frank/ghc-mod-sandbox/bin/:/home/frank/.cabal/bin:/home/frank/Debinstall83/deb9/amd9.bin:/home/frank/.bin:/home/frank/.bin/corenlp:/home/frank/jena/apache-jena-fuseki-2.5.0/bin/:/home/frank/jena/apache-jena-fuseki-2.5.0:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games","SESSION_MANAGER":"local/santafe:@/tmp/.ICE-unix/2279,unix/santafe:/tmp/.ICE-unix/2279","_":"/usr/bin/env"},"encoding":"utf-8","maxBuffer":null}
-23.148s: "Warning: 'dist/setup-config' exists, ignoring Stack project\n"
-23.148s: "Got response from /home/frank/.local/bin/ghc-mod lint,/home/frank/Workspace8/testExample/src/ExampleTesting.hs,--",{"stdout":"","stderr":"Warning: 'dist/setup-config' exists, ignoring Stack project\n"}
-14.993s: "Trying to run ghc-modi in /home/frank/Workspace8/testExample"
-14.993s: "Checking for ghc-modi in /home/frank/Workspace8/testExample"
-14.993s: "Found running ghc-modi instance for /home/frank/Workspace8/testExample"
-14.993s: "Started interactive action block in /home/frank/Workspace8/testExample"
-14.993s: "Running ghc-modi command type","/home/frank/Workspace8/testExample/src/ExampleTesting.hs","-c","--",15,35
-14.928s: "ghc-modi said: cabal-helper-0.7.3.0-Cabal-1.24.2.0: user error (No libraries, executables, tests, or benchmarks are enabled for package testExample-0.0.1.)"
-14.927s: "ghc-modi said: EXCEPTION: types:"
-14.926s: "ghc-modi said:            readCreateProcess: /home/frank/.stack/snapshots/x86_64-linux-nopie/lts-8.1/8.0.2/libexec/x86_64-linux-ghc-8.0.2/cabal-helper-0.7.3.0/cabal-helper-wrapper \"--with-ghc=ghc\" \"--with-ghc-pkg=ghc-pkg\" \"--with-cabal=cabal\" \"/home/frank/Workspace8/testExample\" \"/home/frank/Workspace8/testExample/dist\" \"write-autogen-files\" (exit 1): failed"
-14.926s: "Got response from ghc-modi:\nOK\n"
-14.926s: "Ended interactive action block in /home/frank/Workspace8/testExample"
-14.925s: "Trying to run ghc-modi in /home/frank/Workspace8/testExample"
-14.925s: "Checking for ghc-modi in /home/frank/Workspace8/testExample"
-14.925s: "Found running ghc-modi instance for /home/frank/Workspace8/testExample"
-14.925s: "Started interactive action block in /home/frank/Workspace8/testExample"
-14.925s: "Running ghc-modi command info","/home/frank/Workspace8/testExample/src/ExampleTesting.hs","--","must"
-14.879s: "ghc-modi said: cabal-helper-0.7.3.0-Cabal-1.24.2.0: user error (No libraries, executables, tests, or benchmarks are enabled for package testExample-0.0.1.)"
-14.877s: "ghc-modi said: EXCEPTION: info:"
-14.876s: "ghc-modi said:                readCreateProcess: /home/frank/.stack/snapshots/x86_64-linux-nopie/lts-8.1/8.0.2/libexec/x86_64-linux-ghc-8.0.2/cabal-helper-0.7.3.0/cabal-helper-wrapper \"--with-ghc=ghc\" \"--with-ghc-pkg=ghc-pkg\" \"--with-cabal=cabal\" \"/home/frank/Workspace8/testExample\" \"/home/frank/Workspace8/testExample/dist\" \"write-autogen-files\" (exit 1): failed"
-14.876s: "Got response from ghc-modi:\nCannot show info\nOK\n"
-14.875s: "Ended interactive action block in /home/frank/Workspace8/testExample"
-11.776s: "Trying to run ghc-modi in /home/frank/Workspace8/testExample"
-11.776s: "Checking for ghc-modi in /home/frank/Workspace8/testExample"
-11.776s: "Found running ghc-modi instance for /home/frank/Workspace8/testExample"
-11.776s: "Started interactive action block in /home/frank/Workspace8/testExample"
-11.776s: "Running ghc-modi command type","/home/frank/Workspace8/testExample/src/ExampleTesting.hs","-c","--",6,19
-11.738s: "ghc-modi said: cabal-helper-0.7.3.0-Cabal-1.24.2.0: user error (No libraries, executables, tests, or benchmarks are enabled for package testExample-0.0.1.)"
-11.736s: "ghc-modi said: EXCEPTION: types:"
-11.735s: "ghc-modi said:            readCreateProcess: /home/frank/.stack/snapshots/x86_64-linux-nopie/lts-8.1/8.0.2/libexec/x86_64-linux-ghc-8.0.2/cabal-helper-0.7.3.0/cabal-helper-wrapper \"--with-ghc=ghc\" \"--with-ghc-pkg=ghc-pkg\" \"--with-cabal=cabal\" \"/home/frank/Workspace8/testExample\" \"/home/frank/Workspace8/testExample/dist\" \"write-autogen-files\" (exit 1): failed"
-11.735s: "Got response from ghc-modi:\nOK\n"
-11.735s: "Ended interactive action block in /home/frank/Workspace8/testExample"
-11.735s: "Trying to run ghc-modi in /home/frank/Workspace8/testExample"
-11.735s: "Checking for ghc-modi in /home/frank/Workspace8/testExample"
-11.735s: "Found running ghc-modi instance for /home/frank/Workspace8/testExample"
-11.735s: "Started interactive action block in /home/frank/Workspace8/testExample"
-11.734s: "Running ghc-modi command info","/home/frank/Workspace8/testExample/src/ExampleTesting.hs","--","FlexibleContexts"
-11.692s: "ghc-modi said: cabal-helper-0.7.3.0-Cabal-1.24.2.0: user error (No libraries, executables, tests, or benchmarks are enabled for package testExample-0.0.1.)"
-11.691s: "ghc-modi said: EXCEPTION: info:"
-11.69s: "ghc-modi said:                readCreateProcess: /home/frank/.stack/snapshots/x86_64-linux-nopie/lts-8.1/8.0.2/libexec/x86_64-linux-ghc-8.0.2/cabal-helper-0.7.3.0/cabal-helper-wrapper \"--with-ghc=ghc\" \"--with-ghc-pkg=ghc-pkg\" \"--with-cabal=cabal\" \"/home/frank/Workspace8/testExample\" \"/home/frank/Workspace8/testExample/dist\" \"write-autogen-files\" (exit 1): failed"
-11.69s: "Got response from ghc-modi:\nCannot show info\nOK\n"
-11.69s: "Ended interactive action block in /home/frank/Workspace8/testExample"
-0.079s: "Main did-save triggered"
-0.079s: "Main updating"
-0.078s: "Running /home/frank/.local/bin/ghc-mod check,/home/frank/Workspace8/testExample/src/ExampleTesting.hs,-- with opts = ",{"cwd":"/home/frank/Workspace8/testExample","env":{"ATOM_HOME":"/home/frank/.atom","NODE_PATH":"/usr/share/atom/resources/app.asar/exports","NODE_ENV":"production","LS_COLORS":"","XDG_MENU_PREFIX":"xfce-","LANG":"en_US.utf8","DISPLAY":":0.0","XDG_VTNR":"7","SSH_AUTH_SOCK":"/tmp/ssh-qNxA1dMr81c6/agent.2231","CLASSPATH":"pikes-tintop-1.0-SNAPSHOT-jar-with-dependencies.jar:Semafor-3.0-alpha-04.jar:models/stanford-corenlp-3.5.2-models.jar","GLADE_CATALOG_PATH":":","XDG_SESSION_ID":"4","XDG_GREETER_DATA_DIR":"/var/lib/lightdm/data/frank","USER":"frank","GLADE_MODULE_PATH":":","DESKTOP_SESSION":"lightdm-xsession","PWD":"/home/frank","HOME":"/home/frank","SSH_AGENT_PID":"2269","QT_ACCESSIBILITY":"1","XDG_SESSION_TYPE":"x11","XDG_DATA_DIRS":"/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share","XDG_SESSION_DESKTOP":"lightdm-xsession","GLADE_PIXMAP_PATH":":","DESKTOP_STARTUP_ID":"wrapper-1.0/|usr|share|atom|atom/2337-2-santafe_TIME7024650","GTK_MODULES":"gail:atk-bridge","SHELL":"/bin/bash","XDG_SEAT_PATH":"/org/freedesktop/DisplayManager/Seat0","XDG_CURRENT_DESKTOP":"XFCE","QT_LINUX_ACCESSIBILITY_ALWAYS_ON":"1","SHLVL":"1","XDG_SEAT":"seat0","LANGUAGE":"en_US:en","GDMSESSION":"lightdm-xsession","LOGNAME":"frank","DBUS_SESSION_BUS_ADDRESS":"unix:path=/run/user/1010/bus","XDG_RUNTIME_DIR":"/run/user/1010","XAUTHORITY":"/home/frank/.Xauthority","XDG_SESSION_PATH":"/org/freedesktop/DisplayManager/Session0","XDG_CONFIG_DIRS":"/etc/xdg","GOOGLE_API_KEY":"AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q","PATH":"/home/frank/.stack/global-project/.stack-work/install/x86_64-linux-nopie/lts-8.8/8.0.2/bin:/home/frank/.stack/snapshots/x86_64-linux-nopie/lts-8.8/8.0.2/bin:/home/frank/.stack/programs/x86_64-linux/ghc-nopie-8.0.2/bin:/home/frank/.local/bin:/home/frank/.local/bin/:/home/frank/ghc-mod-sandbox/bin/:/home/frank/.cabal/bin:/home/frank/Debinstall83/deb9/amd9.bin:/home/frank/.bin:/home/frank/.bin/corenlp:/home/frank/jena/apache-jena-fuseki-2.5.0/bin/:/home/frank/jena/apache-jena-fuseki-2.5.0:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games","SESSION_MANAGER":"local/santafe:@/tmp/.ICE-unix/2279,unix/santafe:/tmp/.ICE-unix/2279","_":"/usr/bin/env"},"encoding":"utf-8","maxBuffer":null}
-0.061s: "Running /home/frank/.local/bin/ghc-mod browse,-d,-p,--,Main with opts = ",{"cwd":"/home/frank/Workspace8/testExample","env":{"ATOM_HOME":"/home/frank/.atom","NODE_PATH":"/usr/share/atom/resources/app.asar/exports","NODE_ENV":"production","LS_COLORS":"","XDG_MENU_PREFIX":"xfce-","LANG":"en_US.utf8","DISPLAY":":0.0","XDG_VTNR":"7","SSH_AUTH_SOCK":"/tmp/ssh-qNxA1dMr81c6/agent.2231","CLASSPATH":"pikes-tintop-1.0-SNAPSHOT-jar-with-dependencies.jar:Semafor-3.0-alpha-04.jar:models/stanford-corenlp-3.5.2-models.jar","GLADE_CATALOG_PATH":":","XDG_SESSION_ID":"4","XDG_GREETER_DATA_DIR":"/var/lib/lightdm/data/frank","USER":"frank","GLADE_MODULE_PATH":":","DESKTOP_SESSION":"lightdm-xsession","PWD":"/home/frank","HOME":"/home/frank","SSH_AGENT_PID":"2269","QT_ACCESSIBILITY":"1","XDG_SESSION_TYPE":"x11","XDG_DATA_DIRS":"/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share","XDG_SESSION_DESKTOP":"lightdm-xsession","GLADE_PIXMAP_PATH":":","DESKTOP_STARTUP_ID":"wrapper-1.0/|usr|share|atom|atom/2337-2-santafe_TIME7024650","GTK_MODULES":"gail:atk-bridge","SHELL":"/bin/bash","XDG_SEAT_PATH":"/org/freedesktop/DisplayManager/Seat0","XDG_CURRENT_DESKTOP":"XFCE","QT_LINUX_ACCESSIBILITY_ALWAYS_ON":"1","SHLVL":"1","XDG_SEAT":"seat0","LANGUAGE":"en_US:en","GDMSESSION":"lightdm-xsession","LOGNAME":"frank","DBUS_SESSION_BUS_ADDRESS":"unix:path=/run/user/1010/bus","XDG_RUNTIME_DIR":"/run/user/1010","XAUTHORITY":"/home/frank/.Xauthority","XDG_SESSION_PATH":"/org/freedesktop/DisplayManager/Session0","XDG_CONFIG_DIRS":"/etc/xdg","GOOGLE_API_KEY":"AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q","PATH":"/home/frank/.stack/global-project/.stack-work/install/x86_64-linux-nopie/lts-8.8/8.0.2/bin:/home/frank/.stack/snapshots/x86_64-linux-nopie/lts-8.8/8.0.2/bin:/home/frank/.stack/programs/x86_64-linux/ghc-nopie-8.0.2/bin:/home/frank/.local/bin:/home/frank/.local/bin/:/home/frank/ghc-mod-sandbox/bin/:/home/frank/.cabal/bin:/home/frank/Debinstall83/deb9/amd9.bin:/home/frank/.bin:/home/frank/.bin/corenlp:/home/frank/jena/apache-jena-fuseki-2.5.0/bin/:/home/frank/jena/apache-jena-fuseki-2.5.0:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games","SESSION_MANAGER":"local/santafe:@/tmp/.ICE-unix/2279,unix/santafe:/tmp/.ICE-unix/2279","_":"/usr/bin/env"},"encoding":"utf-8","maxBuffer":null}
-0.004s: "Warning: 'dist/setup-config' exists, ignoring Stack project\ncabal-helper-0.7.3.0-Cabal-1.24.2.0: user error (No libraries, executables, tests, or benchmarks are enabled for package testExample-0.0.1.)\nghc-mod: readCreateProcess: /home/frank/.stack/snapshots/x86_64-linux-nopie/lts-8.1/8.0.2/libexec/x86_64-linux-ghc-8.0.2/cabal-helper-0.7.3.0/cabal-helper-wrapper \"--with-ghc=ghc\" \"--with-ghc-pkg=ghc-pkg\" \"--with-cabal=cabal\" \"/home/frank/Workspace8/testExample\" \"/home/frank/Workspace8/testExample/dist\" \"write-autogen-files\" (exit 1): failed\n"
-0.004s: "Running /home/frank/.local/bin/ghc-mod check,/home/frank/Workspace8/testExample/src/ExampleTesting.hs,-- failed with ",{"killed":false,"code":1,"signal":null,"cmd":"/home/frank/.local/bin/ghc-mod check /home/frank/Workspace8/testExample/src/ExampleTesting.hs --"}
0s: {"killed":false,"code":1,"signal":null,"cmd":"/home/frank/.local/bin/ghc-mod check /home/frank/Workspace8/testExample/src/ExampleTesting.hs --"}

Error
    at /packages/haskell-ghc-mod/lib/util.coffee:60:26
    at ChildProcess.exithandler (child_process.js:225:5)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Socket.<anonymous> (internal/child_process.js:334:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:493:12)
```

### Commands

```
     -6:27.3.0 core:copy (input.hidden-input)
     -5:42.5.0 tree-view:remove-project-folder (div.header.list-item.project-root-header)
     -5:39.7.0 application:add-project-folder (ol.tree-view.full-menu.list-tree.has-collapsable-children.focusable-panel)
     -5:13 ide-haskell-cabal:test (input.hidden-input)
     -4:35.9.0 ide-haskell-cabal:set-build-target (input.hidden-input)
     -4:22.3.0 ide-haskell-cabal:test (input.hidden-input)
  2x -4:06.3.0 ide-haskell-cabal:build (input.hidden-input)
     -2:00.2.0 atom-save-all:saveAll (input.hidden-input)
     -1:57.2.0 ide-haskell-cabal:build (input.hidden-input)
     -1:28.9.0 ide-haskell-cabal:test (input.hidden-input)
     -0:35.4.0 ide-haskell-cabal:clean (input.hidden-input)
     -0:29.5.0 haskell-ghc-mod:lint-file (input.hidden-input)
     -0:08.2.0 editor:toggle-line-comments (input.hidden-input)
     -0:06.3.0 atom-save-all:saveAll (input.hidden-input)
```

### Non-Core Packages

```
atom-save-all 0.4.1 
autocomplete-haskell 0.7.2 
busy 0.7.0 
git-plus 7.3.3 
haskell-ghc-mod 1.19.9 
ide-haskell 1.9.6 
ide-haskell-cabal 1.9.2 
language-haskell 1.12.1 
```