Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding +RTS to ghc-options fails with an error #102

Closed
csasarak opened this issue Dec 14, 2019 · 14 comments
Closed

Adding +RTS to ghc-options fails with an error #102

csasarak opened this issue Dec 14, 2019 · 14 comments

Comments

@csasarak
Copy link
Contributor

This is a duplicate of an issue in: https://github.com/digital-asset/ghcide/issues/136

I had some +RTS ... -RTS options set for GHC in the ghc-options section of my package.yaml file. Running ghcide in that directory fails with ghcide: target ‘+RTS’ is not a module name or a source file The full output is:

`Step 1/6: Finding files to test in /Users/<user>/<project>
Found 601 files

Step 2/6: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/6, Cradle 1/1: Implicit cradle for /Users/user/project
Cradle {cradleRootDir = "/Users/user/project", cradleOptsProg = CradleAction: stack}

Step 4/6, Cradle 1/1: Loading GHC Session
ghcide: target ‘+RTS’ is not a module name or a source file

I am investigating and can duplicate the problem, but for some reason only with the cabal files generated by stack/hpack. I am going to keep investigating and try to cause the issue with pure cabal in addition to trying to fix it.

@mpickering
Copy link
Collaborator

I can reproduce this by just adding +RTS -s -RTS to the ghc-options stanza in a cabal file. What difficulty are you having?

Patch should be straightforward -- remove any RTS arguments.

@csasarak
Copy link
Contributor Author

csasarak commented Dec 15, 2019

I only see this behavior sometimes. For example, modifying hie-bios's own cabal file and changing the Executable section to add +RTS ... bits:

Executable hie-bios
  Default-Language:     Haskell2010
  Main-Is:              Main.hs
  Other-Modules:        Paths_hie_bios
  ghc-options:          +RTS -s -RTS -Wall 
  HS-Source-Dirs:       exe
  Build-Depends:        base >= 4.9 && < 5
                      , directory
                      , filepath
                      , ghc
                      , hie-bios

And then running hie-bios (maybe this is the step I'm messing up) with:
cabal run hie-bios -- check exe/Main.hs
I get no error.

@fendor
Copy link
Collaborator

fendor commented Dec 15, 2019

When adding to ghc-options, shouldnt it be "-with-rtsopts=-s"? Or is that equivalent? Or is that different?
https://www.haskell.org/cabal/users-guide/developing-packages.html?highlight=ghc%20options#pkg-field-ghc-options

@ndmitchell
Copy link
Contributor

@fendor I think that's about setting the option on the program you can compile, whereas +RTS is passing it to GHC itself.

@csasarak csasarak changed the title Adding +RTS to ghci-options fails with an error Adding +RTS to ghc-options fails with an error Dec 23, 2019
@csasarak csasarak closed this as completed Jan 8, 2020
@drewboardman
Copy link

I'm still seeing this error. Is there a resolution for this?

@fendor
Copy link
Collaborator

fendor commented Jan 29, 2020

@drewboardman The issue should be solved by #106 but there has not been a release since then. Wait for #132 which should be in the next days.

@drewboardman
Copy link

@fendor I have removed the +RTS option in my package.yaml, and I'm still seeing this error in hie. I've ran cabal new-clean and cabal new-build, but I'm still seeing the error. Is there some cache that is being referenced?

@fendor
Copy link
Collaborator

fendor commented Jan 29, 2020

If you delete it from package.yaml you need to generate your *.cabal file by either invoking stack build, or hpack. cabal does not read package.yaml

@drewboardman
Copy link

Thanks @fendor. I was able to get rid of that error message, but now am getting a less useful error:

2020-01-29T11:12:40.660 DEBUG (pid:365027) [language-client-index] - [languageserver.haskell] 2020-01-29 11:12:40.660142828 [ThreadId 15] - Cradle did not load succesfully

This cradle loaded successfully in the past. Is there a way to get more error output than this?

@fendor
Copy link
Collaborator

fendor commented Jan 29, 2020

There should be way more output than that, what else is in the logs? Also, diagnostics and such? Do you have a hie.yaml or something like that?
Does your project build in general?

@drewboardman
Copy link

@fendor

Here is a description of my setup:

haskell/haskell-ide-engine#1613 (comment)

Does your project build in general?

Yes

what else is in the logs?

2020-01-29T11:40:04.216 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:04.215969231 [ThreadId 15] - New cradle: /home/drew/code/xxx/test/src/ProjectName/Tests/DB/Yyy/Thing.hs

2020-01-29T11:40:04.216 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:04.216781942 [ThreadId 15] - Module "/home/drew/code/xxx/test/src/ProjectName/Tests/DB/Yyy/Thing.hs" is loaded by Cradle: Cradle {cradleRootDir = "/home/drew/code/xxx", cradleOptsProg = CradleAction: multi}
2020-01-29 11:40:04.216830878 [ThreadId 15] - Found cradle: Cradle {cradleRootDir = "/home/drew/code/xxx", cradleOptsProg = CradleAction: multi}

2020-01-29T11:40:04.226 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:04.225899913 [ThreadId 5094] - Warning: /home/drew/.cabal/config: Unrecognized field ghc-options on line 18

2020-01-29T11:40:06.867 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:06.867348115 [ThreadId 5096] - Resolving dependencies...

2020-01-29T11:40:08.260 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:08.259871131 [ThreadId 5096] - Build profile: -w ghc-8.6.4 -O1
2020-01-29 11:40:08.259948719 [ThreadId 5096] - In order, the following will be built (use -v for more details):
2020-01-29 11:40:08.259976407 [ThreadId 5096] -  - projectName-0.1 (lib) (configuration changed)

2020-01-29T11:40:08.260 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:08.260008711 [ThreadId 5096] -  - projectName-0.1 (test:test) (configuration changed)

2020-01-29T11:40:08.286 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:08.285872112 [ThreadId 5096] - Configuring library for projectName-0.1..

2020-01-29T11:40:09.724 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:09.724664994 [ThreadId 5094] - Warning: 'ghc-options: -threaded' has no effect for libraries. It should only

2020-01-29T11:40:09.725 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:09.724737361 [ThreadId 5094] - be used for executables.
2020-01-29 11:40:09.724761742 [ThreadId 5094] - Warning: 'ghc-options: -rtsopts' has no effect for libraries. It should only
2020-01-29 11:40:09.724785564 [ThreadId 5094] - be used for executables.

2020-01-29T11:40:10.977 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:10.976835372 [ThreadId 5096] - Preprocessing library for projectName-0.1..

2020-01-29T11:40:10.977 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:10.976915242 [ThreadId 5096] - Building library for projectName-0.1..

2020-01-29T11:40:18.800 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:18.800747763 [ThreadId 5096] - Configuring test suite 'test' for projectName-0.1..

2020-01-29T11:40:20.245 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:20.24548543 [ThreadId 5094] - Warning: 'ghc-options: -threaded' has no effect for libraries. It should only
2020-01-29 11:40:20.24560092 [ThreadId 5094] - be used for executables.

2020-01-29T11:40:20.246 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:20.245659418 [ThreadId 5094] - Warning: 'ghc-options: -rtsopts' has no effect for libraries. It should only
2020-01-29 11:40:20.245709091 [ThreadId 5094] - be used for executables.

2020-01-29T11:40:21.510 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:21.510034098 [ThreadId 5096] - Preprocessing test suite 'test' for projectName-0.1..

2020-01-29T11:40:22.035 DEBUG (pid:375157) [language-client-index] - [languageserver.haskell] 2020-01-29 11:40:22.035578167 [ThreadId 15] - Cradle did not load succesfully

@fendor
Copy link
Collaborator

fendor commented Jan 29, 2020

what is the output of cabal v2-repl test:test (should be the component that is loaded)

@drewboardman
Copy link

drewboardman commented Jan 29, 2020

EDIT: It succeeds

@fendor
Copy link
Collaborator

fendor commented Jan 29, 2020

You can try to install the executable from this project with cabal install exe:hie-bios and then execute hie-bios debug <path to test file> and see if this succeeds. Additionally, you can use hie-bios check <path to test file> which tries to type-check the file. Not sure if the output will be helpful though.
If it debug succeeds, it should print component flags. Try to execute ghc <component-flags> and see if it contains any error messages.
If all this does not help at all, I would recommend to install hie from source and test my suggestion in haskell/haskell-ide-engine#1613 (comment), e.g. hie --debug <path to test file>. This should us give something.

If nothing helps at all, please try to share your project with us (if you did not install hie from source before, I would suggest this option before installing hie from source). If it is confidential, try to reduce it to something that is not confidential and share that (assuming, it reproduces your problem).

EDIT: also, please let's continue the discussion at haskell/haskell-ide-engine#1613 since I believe it is an issue with either hie or some project specific fail.

fendor added a commit to fendor/haskell-ide-engine that referenced this issue Apr 13, 2020
Issue that caused it:
haskell#1725

the problem is that we cant honour the `+RTS` flags, since these need to
be known when GHC is started. However, HIE is the compiler and is
started before we load any component.
Therefore, these options for the different component are unusable and we
strip them here to avoid a bug.
This commit is inspired by
haskell/hie-bios#102
fendor added a commit to haskell/haskell-ide-engine that referenced this issue Apr 14, 2020
Issue that caused it:
#1725

the problem is that we cant honour the `+RTS` flags, since these need to
be known when GHC is started. However, HIE is the compiler and is
started before we load any component.
Therefore, these options for the different component are unusable and we
strip them here to avoid a bug.
This commit is inspired by
haskell/hie-bios#102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants