I get the following error when running ghcide in a project with a cabal.project file in it. Are cabal vs project files supported?
Step 4/6, Cradle 1/1: Loading GHC Session
> cabal: Unrecognised target syntax for ''.
>
ghcide: CradleError (ExitFailure 1) ["Failed to parse result of calling cabal","","cabal: Unrecognised target syntax for ''.\n\n",""]
Here is what I am using for ghc and cabal versions:
~% ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5
~% cabal --version
cabal-install version 3.0.1.0
compiled using version 3.0.2.0 of the Cabal library
Any help would be appreciated.
Yes they are supported.
Can you please share both your cabal.project and your .cabal file?
Also, what is the output of cabal build?
Do you have an explicit hie.yaml? If yes, please share that, too.
I got the same error when I was trying to switch to cabal 3 from stack. It might have to do with new-style builds
The "support" for cabal.project files does not mean multi-component projects work at all (#361 aims to address that). If you have a cabal.project with pacakges: x, y and a directory structure with projects in subdirectories (ex x/x.cabal) then there is no ghcide support yet for this setup.
@fendor correct me if I'm wrong, but the aforementioned "support" means that if there is one package of interest with a someproject.cabal in the root directory you can run ghcide and it can build using the information in cabal.project to find dependencies.
I can push up an example repo if desired.
@TomMD I was unable to even get the project set up by cabal init to load as a cabal project in ghcide.
@Avi-D-coder I'm not sure why you're telling me. If you are looking for support then at the very least that's a different issue and deserves a different ticket. Perhaps not a ticket at all but a query to a forum?
I decided to go ahead and produce an example of broken and working cases so we can be sure we're talking about the same setups. Please see the three examples at https://github.com/TomMD/ghcide-examples. There are:
someproject.cabal tends to work fine.cabal.project doesn't work in lieu of #361, and even then not too well.cabal.project and someproject.cabal works fine wrt editing the local project.My point is that the example you say are working are broken. Try adding a dependency (may require cabal 3). The cradle is not a working cabal cradle, it appears to be the implicit global GHC cradle. Cabal builds correctly, but unordered-containers is not found by ghcide.
ghcide version: 0.1.0 (GHC: 8.8.3) (PATH: /home/user/.cabal/store/ghc-8.8.3/ghcide-0.1.0-9f6f1327f154b66866706aee9ec6f5c729cab9553bf46d1417efd7c9b587c94a/bin/ghcide)
Ghcide setup tester in /home/user/ghcide-examples/working-single-target-project-dot-cabal.
Report bugs at https://github.com/digital-asset/ghcide/issues
Step 1/6: Finding files to test in /home/user/ghcide-examples/working-single-target-project-dot-cabal
Found 2 files
Step 2/6: Looking for hie.yaml files that control setup
Found 1 cradle
Step 3/6, Cradle 1/1: Implicit cradle for /home/user/ghcide-examples/working-single-target-project-dot-cabal
Cradle {cradleRootDir = "/home/user/ghcide-examples/working-single-target-project-dot-cabal", cradleOptsProg = CradleAction: Default}
Step 4/6, Cradle 1/1: Loading GHC Session
Step 5/6: Initializing the IDE
Step 6/6: Type checking the files
File: /home/user/ghcide-examples/working-single-target-project-dot-cabal/src/X.hs
Hidden: no
Range: 2:17-2:36
Source: not found
Severity: DsError
Message:
Could not find module ‘Data.HashMap.Strict’
Perhaps you meant
Data.IntMap.Strict (from containers-0.6.2.1)
Data.Map.Strict (from containers-0.6.2.1)
Files that failed:
* /home/user/ghcide-examples/working-single-target-project-dot-cabal/src/X.hs
Completed (1 file worked, 1 file failed)
@TomMD right, that is what I meant :)
@Avi-D-Coder
Cradle {cradleRootDir = "/home/user/ghcide-examples/working-single-target-project-dot-cabal", cradleOptsProg = CradleAction: Default}
CradleAction: Default indicates that the implicit logic never discovers the cabal cradle. Try an explicit hie.yaml:
cradle:
cabal:
Maybe the error message looks different then.
@fendor That was my first thought as well, I tried many different hie.yaml configs, but nothing worked. I even tried the multi component fork.
With that one this is the error:
ghcide version: 0.1.0 (GHC: 8.8.3) (PATH: /home/user/.cabal/store/ghc-8.8.3/ghcide-0.1.0-9f6f1327f154b66866706aee9ec6f5c729cab9553bf46d1417efd7c9b587c94a/bin/ghcide)
Ghcide setup tester in /home/user/ghcide-examples/working-single-target-project-dot-cabal.
Report bugs at https://github.com/digital-asset/ghcide/issues
Step 1/6: Finding files to test in /home/user/ghcide-examples/working-single-target-project-dot-cabal
Found 2 files
Step 2/6: Looking for hie.yaml files that control setup
Found 1 cradle
Step 3/6, Cradle 1/1: Loading /home/user/ghcide-examples/working-single-target-project-dot-cabal/hie.yaml
Step 4/6, Cradle 1/1: Loading GHC Session
> cabal: Unrecognised target syntax for ''.
>
ghcide: CradleError (ExitFailure 1) ["Failed to parse result of calling cabal","","cabal: Unrecognised target syntax for ''.\n\n",""]
@fendor , yeah i'm getting the same error, I have no idea how to fix it, i'll come back here later to see if there has been progress on fixing the error.
The syntax issue is likely just that your default ghc environment conflicts with the dependencies of the package. I'd call it a bug that ghcide uses the default environment, but in the short term just remove it and keep going:
rm ~/.ghc/x86*/environments/default
I cant reproduce with last ghcide version. Otoh cabalcabal since 3.0.0.0 does not write ghc env files by default (and not sure if ghcide should ignore them).
@joehendrix @Avi-D-coder can you still reproduce the error?
Older cabal's do write the env files by default.