Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass +RTS options to program run with stack exec

Tags:

How do I pass +RTS options to a program run with stack exec?

I've added -rtsopts to ghc-options in my cabal file, and built a program with stack build. If I run the program manually both normal and +RTS command line arguments work:

>.stack-work\dist\ca59d0ab\build\iterate-strict-exe\iterate-strict-exe.exe 25 +RTS -s
OK
   3,758,156,184 bytes allocated in the heap
         297,976 bytes copied during GC
         ...

But if I run it with stack exec only the normal options reach the program

>stack exec iterate-strict-exe -- 25 +RTS -s
OK

Other things that don't work

If I juggle the order of the arguments around as suggested by @epsilonhalbe I get the same result.

>stack exec -- iterate-strict-exe 25 +RTS -s
OK

There doesn't seem to be the suggested --rts-options option to pass to stack exec.

>stack exec --rts-options "-s" -- iterate-strict-exe 25
Invalid option `--rts-options'

Usage: stack exec CMD [-- ARGS (e.g. stack ghc -- X.hs -o x)] ([--plain] |
                  [--[no-]ghc-package-path] [--[no-]stack-exe] [--package ARG])
                  [--help]
  Execute a command

I'm using stack version 1.1.2

>stack --version
Version 1.1.2, Git revision c6dac65e3174dea79df54ce6d56f3e98bc060ecc (3647 commits) x86_64 hpack-0.14.0

The same after a stack upgrade to 1.4.0.


Passing the entire command as a string (another suggestion) results in a command with that name not being found

>stack exec -- "iterate-strict-exe 25 +RTS -s"
Executable named iterate-strict-exe 25 +RTS -s not found on path: ...
like image 389
Cirdec Avatar asked Apr 25 '17 08:04

Cirdec


1 Answers

It looks like you are on Windows and encountering GHC bug #13287 (to be fixed in 8.2). See also stack issues 2022 and 2640. Apparently a workaround is to add --RTS before --, like

stack exec iterate-strict-exe --RTS -- 25 +RTS -s
like image 142
Reid Barton Avatar answered Oct 11 '22 07:10

Reid Barton