haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 211 forks source link

Error loading a project with `build-type: custom` (f.e. cabal-install) #1638

Open flip111 opened 4 years ago

flip111 commented 4 years ago
2020-02-04 19:52:42.9639947 [ThreadId 3] - ---> {"jsonrpc":"2.0","id":394,"method":"textDocument/references","params":{"textDocument":{"uri":"file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"},"position":{"line":1416,"character":16},"context":{"includeDeclaration":true}}}
2020-02-04 19:52:42.9639947 [ThreadId 25] - ****** reactor: got message number:461
2020-02-04 19:52:42.9639947 [ThreadId 25] - reactor:got FindReferences:RequestMessage {_jsonrpc = "2.0", _id = IdInt 394, _method = TextDocumentReferences, _params = ReferenceParams {_textDocument = TextDocumentIdentifier {_uri = Uri {getUri = "file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"}}, _position = Position {_line = 1416, _character = 16}, _context = ReferenceContext {_includeDeclaration = True}, _workDoneToken = Nothing}}
2020-02-04 19:52:42.9639947 [ThreadId 25] - ****** reactor: top of loop
2020-02-04 19:52:42.9639947 [ThreadId 31] - ideDispatcher: got request 461 with id: IdInt 394
2020-02-04 19:52:42.9649911 [ThreadId 31] - ideDispatcher: top of loop

https://github.com/haskell/cabal/blob/ac84fa2f25505ed604769d6fc3f00ecf3933b248/cabal-install/Distribution/Client/ProjectPlanning.hs#L1417

fendor commented 4 years ago

Maybe project failed to load? Are hover requests working?

flip111 commented 4 years ago

I restarted vs code (the editor that i'm using) seems that this issue is first stuck on another issue

Fail on initialisation for "C:\Users\flip111\haskell\cabal\cabal-install\Distribution\Client\ProjectPlanning.hs". Could not obtain flags for: "Distribution\Client\ProjectPlanning.hs".

projectplanning_hie_log.txt

Or maybe it's the same issue but another manifestation of it.

fendor commented 4 years ago

there should be a diagnostic in the first line with more infos

flip111 commented 4 years ago

First line where ?

fendor commented 4 years ago

In the file you load, there should be a diagnostic in the first line. In the logs, you see the full error message, too.

Could not obtain flags for: "Distribution\Client\ProjectPlanning.hs".

We could not build all components.
If one of these components exposes this Module, make sure they compile.
You can try to invoke the commands yourself.
The following commands failed:

callProcessStderr: cabal v2-build --with-ghc=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc.exe --with-ghc-pkg=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe --with-haddock=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\haddock.exe --project-file=C:\Users\flip111\haskell\cabal\cabal.project --builddir=C:\Users\flip111\haskell\cabal\dist-newstyle --only-configure cabal-install:exe:cabal cabal-install:setup (exit 1): failed

Calling the command cabal v2-build --with-ghc=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc.exe --with-ghc-pkg=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe --with-haddock=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\haddock.exe --project-file=C:\Users\flip111\haskell\cabal\cabal.project --builddir=C:\Users\flip111\haskell\cabal\dist-newstyle --only-configure cabal-install:exe:cabal cabal-install:setup will show you the exact error message

flip111 commented 4 years ago

Error:

The given project file 'C:Usersflip111haskellcabalcabal.project' does not exist.

Looks that somewhere windows paths are not properly handled

fendor commented 4 years ago

interesting, could be a cabal bug. Needs more investigating. cc @jneira you have never encountered something like that before, right?

flip111 commented 4 years ago

Do you think it's worth to report upstream ?

fendor commented 4 years ago

Probably, if you can provide a nice way to reproduce the issue.

flip111 commented 4 years ago

I think i launched that command from a mingw shell. When i launch from cmd.exe i get the following

cabal: Unknown target 'cabal-install:setup'.
The package cabal-install has no component 'setup'.
jneira commented 4 years ago

I will try to load cabal in my local to reproduce it

jneira commented 4 years ago

I've just adding:

build-type: custom
custom-setup
   setup-depends:
       base

to a simple, working cabal project and i've got the same error so i am afraid that the error is generic. cabal-helper tries to configure a component named package:setup that simply does not exist. I guess the fix would be in cabal-helper itself but further investigation is needed.

@fendor could you comfirm that it is reproduced in linux, please?

jneira commented 4 years ago

workarounds:

fendor commented 4 years ago

Can reproduce on linux as well. Adds a component package:setup Note, my custom setup looks like:


build-type: Custom
custom-setup
  setup-depends: base, Cabal
flip111 commented 4 years ago

@jneira with which package is the root cause of this? Is it cabal-helper? Would reporting upstream be helpful?

I can not use the workaround to drop the custom setup because the project is cabal itself (cloned from github) and i'm sure the cabal developers have their good reasons to do a custom setup.

What should go into hie.yaml for the second workaround ?

fendor commented 4 years ago

It seems to be an issue with cabal-helper. My hie.yaml looks like this:

cradle:
  cabal:
    - path: ./cabal-install
      component: "exe:cabal"
    - path: ./Cabal
      component: "lib:Cabal"
jneira commented 4 years ago

I can not use the workaround to drop the custom setup because the project is cabal itself (cloned from github) and i'm sure the cabal developers have their good reasons to do a custom setup.

well, examining the Setup.hs, it seems it generates the manpages so maybe it is no essential for your actual work on cabal But i agree the cleaner workaround is adding a hie.yaml

Would reporting upstream be helpful?

just @fendor has confimed me that cabal-helper is choosing the targets so it is the appropiate thing to do