Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

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

Open
flip111 opened this issue Feb 4, 2020 · 17 comments
Open

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

flip111 opened this issue Feb 4, 2020 · 17 comments

Comments

@flip111
Copy link
Contributor

flip111 commented Feb 4, 2020

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
Copy link
Collaborator

fendor commented Feb 4, 2020

Maybe project failed to load? Are hover requests working?

@flip111
Copy link
Contributor Author

flip111 commented Feb 4, 2020

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
Copy link
Collaborator

fendor commented Feb 4, 2020

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

@flip111
Copy link
Contributor Author

flip111 commented Feb 4, 2020

First line where ?

@fendor
Copy link
Collaborator

fendor commented Feb 4, 2020

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
Copy link
Contributor Author

flip111 commented Feb 4, 2020

Error:

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

Looks that somewhere windows paths are not properly handled

@fendor
Copy link
Collaborator

fendor commented Feb 4, 2020

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

@flip111
Copy link
Contributor Author

flip111 commented Feb 4, 2020

Do you think it's worth to report upstream ?

@fendor
Copy link
Collaborator

fendor commented Feb 4, 2020

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

@flip111
Copy link
Contributor Author

flip111 commented Feb 4, 2020

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
Copy link
Member

jneira commented Feb 5, 2020

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

@jneira jneira self-assigned this Feb 5, 2020
@jneira jneira changed the title hie doesn't respond to request for all references Error loading a project with build-type: custom (f.e. cabal-install) Feb 5, 2020
@jneira
Copy link
Member

jneira commented Feb 5, 2020

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
Copy link
Member

jneira commented Feb 5, 2020

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)

@fendor
Copy link
Collaborator

fendor commented Feb 5, 2020

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

@jneira jneira removed their assignment Feb 5, 2020
@flip111
Copy link
Contributor Author

flip111 commented Feb 5, 2020

@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
Copy link
Collaborator

fendor commented Feb 5, 2020

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
Copy link
Member

jneira commented Feb 5, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants