haskell-ide-engine icon indicating copy to clipboard operation
haskell-ide-engine copied to clipboard

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

Open flip111 opened this issue 4 years ago • 17 comments

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

flip111 avatar Feb 04 '20 18:02 flip111

Maybe project failed to load? Are hover requests working?

fendor avatar Feb 04 '20 18:02 fendor

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.

flip111 avatar Feb 04 '20 19:02 flip111

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

fendor avatar Feb 04 '20 19:02 fendor

First line where ?

flip111 avatar Feb 04 '20 20:02 flip111

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

fendor avatar Feb 04 '20 21:02 fendor

Error:

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

Looks that somewhere windows paths are not properly handled

flip111 avatar Feb 04 '20 22:02 flip111

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

fendor avatar Feb 04 '20 22:02 fendor

Do you think it's worth to report upstream ?

flip111 avatar Feb 04 '20 23:02 flip111

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

fendor avatar Feb 04 '20 23:02 fendor

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'.

flip111 avatar Feb 04 '20 23:02 flip111

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

jneira avatar Feb 05 '20 06:02 jneira

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 avatar Feb 05 '20 11:02 jneira

workarounds:

  • remove the build-type: custom and custom-setup from .cabal and lose the custom processing (maybe it is not needed for your actual interest in the project)
  • create a explicit hie.yaml to bypass cabal-helper (i've tested it in the simple cabal project and it worked)

jneira avatar Feb 05 '20 11:02 jneira

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

fendor avatar Feb 05 '20 11:02 fendor

@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 ?

flip111 avatar Feb 05 '20 12:02 flip111

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"

fendor avatar Feb 05 '20 12:02 fendor

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

jneira avatar Feb 05 '20 12:02 jneira