Skip to content

Error when using RTS options with the Stack script interpreter #3658

Closed
@danclien

Description

@danclien

General

Using Stack as a script interpreter doesn't accept RTS options as noted in the Stack documentation.

I'm not sure if there's a bug with Stack or an error in the documentation.

Steps to reproduce

  1. Put the following in a file:
    #!/usr/bin/env stack
    {- stack
      script
      --resolver lts-6.25
      --package turtle
      --
      +RTS -s -RTS
    -}
    
    main :: IO
    main = putStrLn "Hello, world!"
    
  2. Make the file executable
    $ chmod +x <file>
    
  3. Execute the file
    $ ./<file>
    

Expected

The script should print Hello, world!.

Actual

The script errors out with the following:

target ‘+RTS’ is not a module name or a source file

Output

$ stack --version
Version 1.6.1, Git revision f25811329bbc40b0c21053a8160c56f923e1201b (5435 commits) x86_64 hpack-0.20.0
$ cat ./StackScriptTest.hs
#!/usr/bin/env stack
{- stack
  script
  --resolver lts-6.25
  --package turtle
  --
  +RTS -s -RTS
-}

main :: IO
main = putStrLn "Hello, world!"
$ ./StackScriptTest.hs
target ‘/home/dacali/projects/onefile/+RTS’ is not a module name or a source file

Stack version

$ stack --version
Version 1.6.1, Git revision f25811329bbc40b0c21053a8160c56f923e1201b (5435 commits) x86_64 hpack-0.20.0

Method of installation

  • Upgraded with stack upgrade

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions