tfausak / purple-yolk

:hatching_chick: A Haskell IDE for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=taylorfausak.purple-yolk
MIT License
26 stars 2 forks source link

GHC Arg Error #19

Closed s0kil closed 3 years ago

s0kil commented 3 years ago

There is an error on start: option -j: cannot parse value `-O0'

Seems the first O should be 0 (zero)

tfausak commented 3 years ago

It looks like -O0 is being interpreted as an argument to -j rather than as a separate flag. In other words it's doing something like -j=-O0. That's odd. -j by itself is supposed to mean "use all cores", which is the behavior I want.

Which version of GHC are you using? And which operating system are you on?

s0kil commented 3 years ago
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.2
$ stack --version
Version 2.3.3, Git revision cb44d51bed48b723a5deb08c3348c0b3ccfc437e x86_64 hpack-0.33.0
$ uname -a
Linux pop-os 5.8.7-050807-generic #202009051031 SMP Sat Sep 5 10:34:16 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Pop
Description:    Pop!_OS 20.04 LTS
Release:    20.04
Codename:   focal
s0kil commented 3 years ago

Running

$ stack --color never --no-terminal ghci --ghc-options "-ddump-json -j -00" --main-is base --test

in project directory works.

Here is the issue:

$ stack --color never --no-terminal ghci --ghc-options "-ddump-json -j -O0" --main-is base --test
option -j: cannot parse value `-O0'

Usage: stack ghci [TARGET/FILE] [--pedantic] [--ghci-options OPTIONS]
                  [--ghc-options OPTIONS] [--flag PACKAGE:[-]FLAG]
                  [--with-ghc GHC] [--[no-]load] [--package ARG]
                  [--main-is TARGET] [--load-local-deps] [--[no-]package-hiding]
                  [--only-main] [--trace] [--profile] [--no-strip] [--[no-]test]
                  [--[no-]bench] [--setup-info-yaml URL] [--help]
  Run ghci in the context of package(s) (experimental)
tfausak commented 3 years ago

Ah, interesting! The error is coming from Stack, not GHC.

~> stack --version
Version 2.3.3, Git revision cb44d51bed48b723a5deb08c3348c0b3ccfc437e x86_64 hpack-0.33.0
~> stack -j-O0
option -j: cannot parse value `-O0'
...
~> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.1
~> ghc -j-O0
ghc: on the commandline: malformed integer argument in -j-O0
...

That suggests the quoting is not working as expected. I would ask which shell you're using, but all of them should handle double quotes just fine.

What does Purple Yolk's output look like? I see this:

Click to expand.
``` [Info - 10:17:40 PM] 0.115 Initializing purple-yolk 0.2.1 [Info - 10:17:40 PM] 0.146 Starting GHCi: stack --color never --no-terminal ghci --ghc-options "-ddump-json -j -O0" --main-is base --test [Info - 10:17:40 PM] 0.153 Queueing :set prompt "{- purple-yolk 0.2.1 1601518660800.039 -}\n" [Info - 10:17:40 PM] 0.154 Starting :set prompt "{- purple-yolk 0.2.1 1601518660800.039 -}\n" after 0.000 [Info - 10:17:40 PM] 0.154 Queueing :set -ddump-json [Info - 10:17:40 PM] 0.154 Queueing :reload [Info - 10:17:41 PM] 0.635 [stderr] grog> configure (lib + exe + test) [Info - 10:17:41 PM] 1.124 [stderr] Configuring grog-0.0.0.0... [Info - 10:17:42 PM] 1.343 [stderr] grog> initial-build-steps (lib + exe + test) [Info - 10:17:42 PM] 1.367 [stderr] grog> Test running disabled by --no-run-tests flag. [Info - 10:17:42 PM] 1.367 [stderr] Completed 2 action(s). [Info - 10:17:42 PM] 1.505 [stderr] The following GHC options are incompatible with GHCi and have not been passed to it: -threaded [Info - 10:17:42 PM] 1.506 [stderr] Configuring GHCi with the following packages: grog [Info - 10:17:42 PM] 1.610 [stdout] GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help [Info - 10:17:42 PM] 1.715 [stdout] Loaded GHCi configuration from /home/taylor/.ghci [Info - 10:17:43 PM] 2.838 [stdout] Ok, 38 modules loaded. [Info - 10:17:43 PM] 2.864 [stdout] Loaded GHCi configuration from /tmp/haskell-stack-ghci/25a413e8/ghci-script [Info - 10:17:43 PM] 2.865 Finished :set prompt "{- purple-yolk 0.2.1 1601518660800.039 -}\n" in 2.711 [Info - 10:17:43 PM] 2.865 Starting :set -ddump-json after 2.711 [Info - 10:17:43 PM] 2.866 Finished :set -ddump-json in 0.001 [Info - 10:17:43 PM] 2.866 Starting :reload after 2.711 [Info - 10:17:43 PM] 2.923 [stdout] Ok, 38 modules loaded. [Info - 10:17:43 PM] 2.952 Finished :reload in 0.086 ```
For a workaround you could try using single quotes instead of double quotes. That's what I had originally but I changed it to support Windows.
s0kil commented 3 years ago

Here is the extension output using the default setting:

[Info  - 10:26:46 PM] 0.161 Initializing purple-yolk 0.2.1
[Info  - 10:26:46 PM] 0.627 Starting GHCi: stack --color never --no-terminal ghci --ghc-options "-ddump-json -j -O0" --main-is base --test
[Info  - 10:26:46 PM] 0.638 Queueing :set prompt "{- purple-yolk 0.2.1 1601519206151.782 -}\n"
[Info  - 10:26:46 PM] 0.638 Starting :set prompt "{- purple-yolk 0.2.1 1601519206151.782 -}\n" after 0.000
[Info  - 10:26:46 PM] 0.640 Queueing :set -ddump-json
[Info  - 10:26:47 PM] 0.640 Queueing :reload
/home/danielsokil/.vscode/extensions/taylorfausak.purple-yolk-0.2.1/dist/server.js:1
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=62)}([fun

Error: GHCi exited with code 1 and signal null!
    at ChildProcess.<anonymous> (/home/danielsokil/.vscode/extensions/taylorfausak.purple-yolk-0.2.1/dist/server.js:1:73404)
    at ChildProcess.emit (events.js:223:5)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
[Info  - 10:26:48 PM] 1.363 [stderr] option -j: cannot parse value `-O0'
[Info  - 10:26:48 PM] Connection to server got closed. Server will restart.
[Info  - 10:26:48 PM] 0.224 Initializing purple-yolk 0.2.1
[Info  - 10:26:48 PM] 0.232 Starting GHCi: stack --color never --no-terminal ghci --ghc-options "-ddump-json -j -O0" --main-is base --test
[Info  - 10:26:48 PM] 0.241 Queueing :set prompt "{- purple-yolk 0.2.1 1601519208519.986 -}\n"
[Info  - 10:26:48 PM] 0.241 Starting :set prompt "{- purple-yolk 0.2.1 1601519208519.986 -}\n" after 0.000
[Info  - 10:26:48 PM] 0.242 Queueing :set -ddump-json
[Info  - 10:26:48 PM] 0.242 Queueing :reload
[Info  - 10:26:49 PM] 0.778 [stderr] option -j: cannot parse value `-O0'
[Info  - 10:26:49 PM] 0.778 [stderr] 
[Info  - 10:26:49 PM] 0.778 [stderr] Usage: stack ghci [TARGET/FILE] [--pedantic] [--ghci-options OPTIONS]
[Info  - 10:26:49 PM] 0.778 [stderr]                   [--ghc-options OPTIONS] [--flag PACKAGE:[-]FLAG]
[Info  - 10:26:49 PM] 0.778 [stderr]                   [--with-ghc GHC] [--[no-]load] [--package ARG]
[Info  - 10:26:49 PM] 0.779 [stderr]                   [--main-is TARGET] [--load-local-deps] [--[no-]package-hiding]
[Info  - 10:26:49 PM] 0.779 [stderr]                   [--only-main] [--trace] [--profile] [--no-strip] [--[no-]test]
[Info  - 10:26:49 PM] 0.779 [stderr]                   [--[no-]bench] [--setup-info-yaml URL] [--help]
[Info  - 10:26:49 PM] 0.779 [stderr]   Run ghci in the context of package(s) (experimental)

The output with default setting overwriten:

[Info  - 10:28:34 PM] 0.159 Initializing purple-yolk 0.2.1
[Info  - 10:28:34 PM] 0.372 Starting GHCi: stack --color never --no-terminal ghci --ghc-options "-ddump-json -j -00" --main-is base --test
[Info  - 10:28:34 PM] 0.411 Queueing :set prompt "{- purple-yolk 0.2.1 1601519314183.002 -}\n"
[Info  - 10:28:34 PM] 0.412 Starting :set prompt "{- purple-yolk 0.2.1 1601519314183.002 -}\n" after 0.001
[Info  - 10:28:34 PM] 0.418 Queueing :set -ddump-json
[Info  - 10:28:34 PM] 0.418 Queueing :reload
[Info  - 10:28:38 PM] 2.834 [stderr] Practical-Haskell> configure (lib + exe + test)
[Info  - 10:28:38 PM] 3.836 [stderr] Configuring Practical-Haskell-0.1.0.0...
[Info  - 10:28:38 PM] 4.216 [stderr] Practical-Haskell> initial-build-steps (lib + exe + test)
[Info  - 10:28:39 PM] 4.911 [stderr] Practical-Haskell> Test running disabled by --no-run-tests flag.
[Info  - 10:28:39 PM] 4.911 [stderr] Completed 2 action(s).
[Info  - 10:28:39 PM] 5.013 [stderr] The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
[Info  - 10:28:39 PM] 5.013 [stderr] Configuring GHCi with the following packages: Practical-Haskell
[Info  - 10:28:39 PM] 5.087 [stdout] GHCi, version 8.10.2: https://www.haskell.org/ghc/  :? for help
[Info  - 10:28:39 PM] 5.304 [stdout] Ok, two modules loaded.
[Info  - 10:28:39 PM] 5.305 [stdout] Loaded GHCi configuration from /tmp/haskell-stack-ghci/3017015d/ghci-script
[Info  - 10:28:39 PM] 5.305 Finished :set prompt "{- purple-yolk 0.2.1 1601519314183.002 -}\n" in 4.893
[Info  - 10:28:39 PM] 5.306 Starting :set -ddump-json after 4.888
[Info  - 10:28:39 PM] 5.306 Finished :set -ddump-json in 0.001
[Info  - 10:28:39 PM] 5.307 Starting :reload after 4.889
[Info  - 10:28:39 PM] 5.308 [stdout] Ok, two modules loaded.
[Info  - 10:28:39 PM] 5.308 Finished :reload in 0.002
[Info  - 10:28:40 PM] 6.449 Saved file:///home/danielsokil/Study/Practical-Haskell/src/Chapter2/Section3/DataTypes.hs
[Info  - 10:28:40 PM] 6.449 Queueing :reload
[Info  - 10:28:40 PM] 6.449 Starting :reload after 0.000
[Info  - 10:28:40 PM] 6.478 [stdout] Ok, two modules loaded.
[Info  - 10:28:40 PM] 6.478 Finished :reload in 0.029
s0kil commented 3 years ago

Ah, interesting! The error is coming from Stack, not GHC.

~> stack --version
Version 2.3.3, Git revision cb44d51bed48b723a5deb08c3348c0b3ccfc437e x86_64 hpack-0.33.0
~> stack -j-O0
option -j: cannot parse value `-O0'
...
~> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.1
~> ghc -j-O0
ghc: on the commandline: malformed integer argument in -j-O0
...

Not sure what you mean, the ghc -j-O0 you showed is still throwing an error.

tfausak commented 3 years ago

You're right, GHC still throws an error. What I meant to point out was that the errors are different. The one you're seeing comes from Stack, not GHC. That's interesting to me because it means the arguments are being passed to Stack instead of GHC even though they're quoted.

Changing -O0 to -00 works because Stack interprets -00 as an argument to -j. It's effectively the same as saying --jobs 0. (For what it's worth GHC would refuse this argument because it requires -j to be greater than 0.)

There are a few things I can think of that might fix this error but keep the behavior I'm after:

I'd like to get to the bottom of this because it's such a puzzling error, but at the same time I understand if you don't want to spend time trying out a bunch of different configurations :smile:

s0kil commented 3 years ago

Manually splitting GHC options works as expected. Using single quotes throws the same error. Removing --no-terminal options throws the same error.

tfausak commented 3 years ago

Thanks for sticking with this! Version 0.2.2 should fix the problem with the default command.