haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

(GhcSession,NormalizedFilePath) target ‘+RTS’ is not a module name or a source file

Open tchoutri opened this issue 7 months ago • 5 comments

  • HLS 2.10.0.0
  • GHC 9.10.1

While working on the flora codebase, I enabled multipleComponents in my LSP client, which led me to encounter a very strange error message:

Diagnostics:
1. (GhcSession,NormalizedFilePath "/home/tchoutri/Projects/Flora/1-flora-server/src/core/Flora/Model/
  PackageGroup/Query.hs")target ‘+RTS’ is not a module name or a source file

I indeed set RTS options in my cabal.project file, but I have a hard time understanding why this would be used in any kind of file paths.

tchoutri avatar May 20 '25 17:05 tchoutri

Hi, could you provide the logs? haskell-language-server --debug src/core/Flora/Model/PackageGroup/Query.hs should suffice. I am looking for lines that start with Debug | Session loading result: Right (ComponentOptions. It should list the exact options, telling us what is going wrong.

fendor avatar May 21 '25 10:05 fendor

@fendor Sure. Can I write the configuration json in a specific file for HLS to pick it up in my project?

tchoutri avatar May 21 '25 10:05 tchoutri

oh, I forgot about that detail. We should extend the CLI interface :( Sorry, then I would ask for the logs from your editor, pretty please :)

fendor avatar May 21 '25 11:05 fendor

@fendor No mention of RTS in the logs:

Details

810:[ERROR][2025-05-21 13:20:11] /usr/share/nvim/runtime/lua/vim/lsp/_transport.lua:36	"rpc"	"/home/tchoutri/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	'2025-05-21T11:20:11.359087Z | Debug | Session loading result: Right (ComponentOptions {componentOptions = ["-fbuilding-cabal-package","-O0","-outputdir","/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build","-odir","/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build","-hidir","/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build","-hiedir","/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build/extra-compilation-artifacts/hie","-stubdir","/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build","-i","-i./src/core","-i./src/datatypes","-i/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build","-i/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build/autogen","-i/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build/global-autogen","-I/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build/autogen","-I/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build/global-autogen","-I/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build","-optP-include","-optP/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/build/autogen/cabal_macros.h","-this-unit-id","flora-1.0.25-inplace","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/home/tchoutri/.cabal/store/ghc-9.10.1-803c/package.db","-package-db","/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/packagedb/ghc-9.10.1","-package-db","/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/build/x86_64-linux/ghc-9.10.1/flora-1.0.25/package.conf.inplace","-package-id","Cabal-syntax-3.12.0.0-6c8a","-package-id","JuicyPixels-3.3.9-10f0ccf2c814e259a93b210db249e31d8cddeb0158f3791bb119eb54deba60b1","-package-id","aeson-2.2.3.0-e9644ba2343df677ae990a6f66c5249c9a2bf91ce1d6dc38b0cad53c3b47c645","-package-id","attoparsec-0.14.4-32370d69023b0436cb2bb566c560044bbfc62d96fb09c57c4e2a0faeb47909d4","-package-id","base-4.20.0.0-8212","-package-id","base16-bytestring-1.0.2.0-ce6405b183a95cdb97632d72655c18a766c73cf6b3ce8e6ae66541fb74ccba99","-package-id","base64-1.0-5cdcbc5a2fc120568e3d51d25bbc11d6de84c81dda4ca5f4a68902c4e3726394","-package-id","bytestring-0.12.1.0-6739","-package-id","containers-0.7-94b0","-package-id","cryptohash-md5-0.11.101.0-2d0324095b62c82d836430e39ab38382547e385eade18e5ee20ec56e378a393b","-package-id","cryptohash-sha256-0.11.102.1-1d24ded29a59207812a80dd8a590a2803937f66c61323cb7028e7ff40539be6c","-package-id","cvss-0.2-7170194f7a1528a46172fc65954d6c58ce62bb509cffe597179bf067bbf864ee","-package-id","dani-servant-lucid2-0.1.0.0-2082ea6f41f371ed0fd9b64a7ba25dfa42fd702e068bcd2b7c4f81d1ecc1f0a5","-package-id","deepseq-1.5.0.0-cd1e","-package-id","deriving-aeson-0.2.10-f7be8dd1fe57106cc10df474103ff4396822fa046e6223208a31eff1d944cc80","-package-id","directory-1.3.8.3-5cf8","-package-id","effectful-2.5.1.0-3ab9c9c412625339f8ba18062bcabab48128b5e33bf8b73e6128cb38612c5256","-package-id","effectful-core-2.5.1.0-229596ebb0a6143e1bce9fd3c9418425da56acff0038fa5122de9198c0ca9c13","-package-id","effectful-plugin-1.1.0.4-b10c4361f20f28de55b8de368e171472209f6dc7f78d085409d8c05f8ecf515d","-package-id","envparse-0.6.0-abcebf5f6dd63f4a13ddefce38bd0dfb6e88ad3a0c479e14e5801a43b2024222","-package-id","filepath-1.5.2'

1013:[ERROR][2025-05-21 13:21:48] /usr/share/nvim/runtime/lua/vim/lsp/_transport.lua:36	"rpc"	"/home/tchoutri/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	'2025-05-21T11:21:48.493649Z | Debug | Session loading result: Right (ComponentOptions {componentOptions = ["-package-env","-","-j","12","-unit","@/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/multi-out-96512/flora-1.0.25-inplace","-unit","@/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/multi-out-96512/flora-1.0.25-inplace-flora-jobs","-unit","@/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/multi-out-96512/flora-1.0.25-inplace-flora-advisories","-unit","@/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/multi-out-96512/flora-1.0.25-inplace-flora-search","-unit","@/home/tchoutri/.cache/hie-bios/dist-1-flora-server-466e17a50ced3b00c7ac70e94842a281/multi-out-96512/flora-1.0.25-inplace-flora-web"], componentRoot = "/home/tchoutri/Projects/Flora/1-flora-server", componentDependencies = ["flora.cabal","cabal.project","cabal.project.local"]},"/home/tchoutri/.ghcup/ghc/9.10.1/lib/ghc-9.10.1/lib","9.10.1")\n'

tchoutri avatar May 21 '25 11:05 tchoutri

It looks like cabal repl ... passes +RTS flags to the ghc arguments in -unit @unitArgs. The args are in @unitArgs. There seem to be two issues:

  • cabal should likely not pass +RTS arguments via @unitArgs. The RTS arguments don't mean anything per unit, so should likely be passed on the top, e.g. ghc --interactive -unit @unitArgs +RTS -A32m.
  • hie-bios should filter these arguments out, but it doesn't, because hie-bios doesn't validate (or make the ghc options absolute). The arguments are processed in HLS

So, we can fix it in hie-bios or HLS, but arguably we also should patch cabal, I believe. @mpickering do you agree?

fendor avatar May 21 '25 16:05 fendor

This should be fixed by #4647 and included in HLS 2.12

fendor avatar Oct 06 '25 17:10 fendor