Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify session loading using implicit-hie #1783

Merged
merged 3 commits into from
May 2, 2021
Merged

Conversation

fendor
Copy link
Collaborator

@fendor fendor commented Apr 30, 2021

Make Wrapper and Session loader use the same logic to avoid
loading logic divergence.

Cleans up existing usages to use infrastructure in place.

Closes #1782

@fendor
Copy link
Collaborator Author

fendor commented Apr 30, 2021

@emilypi Would you mind trying if this fixes your issue?

@fendor fendor force-pushed the fix/1782 branch 3 times, most recently from 1730357 to 73b472a Compare April 30, 2021 20:35
@fendor fendor requested review from Ailrun and pepeiborra and removed request for Ailrun April 30, 2021 20:35
Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we know that this fixes the issue? It would be great to have a test

ghcide/session-loader/Development/IDE/Session.hs Outdated Show resolved Hide resolved
@fendor
Copy link
Collaborator Author

fendor commented Apr 30, 2021

I think, we need end-to-end tests to truly prove the issue doesn't occur anymore. The issue was basically that Wrapper and HLS didn't use the same logic for loading a cradle, thus, came to different conclusions regarding the cradle type. As we now unified the logic behaviour, e.g. there is only a single occurence of loadCradle from hie-bios and loadImplicitHieCradle respectively, it should be fixed. (yeah, I know, that is not a test)

Do we have something resembling end-to-end tests?

@jneira
Copy link
Member

jneira commented Apr 30, 2021

Do we have something resembling end-to-end tests?

Execute hls-wrapper and hls in a test directory as cli and comparing their outputs about loading the cradle could work?
Maybe if they would have an option to output the cradle loading info, the test could be easier

@emilypi
Copy link
Member

emilypi commented Apr 30, 2021

@fendor I can confirm this works, calling the executable with HEAD on your branch:

λ athena pact → λ git fix-modref-json* → ../haskell-language-server/dist-newstyle/build/x86_64-linux/ghc-8.8.4/haskell-language-server-1.1.0.0/x/haskell-language-server-wrapper/noopt/build/haskell-language-server-wrapper/haskell-language-server-wrapper

No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.1.0.0, Git revision 73b472ae33b14d68c6071f01ce85d349ca8ac3ce (2196 commits) x86_64 ghc-8.8.4
Current directory: /home/tapas/haskell/pact
Operating system: linux
Arguments: []
Cradle directory: /home/tapas/haskell/pact
Cradle type: Cabal

Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.5.1
ghc:		8.8.4


Consulting the cradle to get project GHC version...
Project GHC version: 8.8.4
haskell-language-server exe candidates: ["haskell-language-server-8.8.4","haskell-language-server-8.8","haskell-language-server"]
Launching haskell-language-server exe at:/home/tapas/.ghcup/bin/haskell-language-server-8.8.4
haskell-language-server version: 1.1.0.0 (GHC: 8.8.4) (PATH: /home/tapas/.ghcup/bin/haskell-language-server-8.8.4~1.1.0) (GIT hash: f1c096927186a93d8e3ccd4fe8385cc1b070350b)
 ghcide setup tester in /home/tapas/haskell/pact.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /home/tapas/haskell/pact
Found 154 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  ()

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2021-04-30 19:03:43.657015867 [ThreadId 180] INFO hls:	Consulting the cradle for "src/Pact/Native/Decrypt.hs"
2021-04-30 19:03:43.657125598 [ThreadId 180] WARNING hls:	No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for src/Pact/Native/Decrypt.hs.
 Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
Output from setting up the cradle Cradle {cradleRootDir = "/home/tapas/haskell/pact", cradleOptsProg = CradleAction: Cabal}
> Build profile: -w ghc-8.8.4 -O0
> In order, the following will be built (use -v for more details):
>  - pact-3.7 (lib) (ephemeral targets)
> Preprocessing library for pact-3.7..
2021-04-30 19:03:44.221938537 [ThreadId 180] INFO hls:	Using interface files cache dir: /home/tapas/.cache/ghcide/pact-3.7-inplace-64068f8443af49203e4e0b3f9e4d9e46a17947f8
2021-04-30 19:03:44.222399518 [ThreadId 180] INFO hls:	Making new HscEnv[pact-3.7-inplace]
2021-04-30 19:03:44.55223189 [ThreadId 346] INFO hls:	Consulting the cradle for "tests/RemoteVerifySpec.hs"
2021-04-30 19:03:44.552312195 [ThreadId 346] WARNING hls:	No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for tests/RemoteVerifySpec.hs.
 Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
Output from setting up the cradle Cradle {cradleRootDir = "/home/tapas/haskell/pact", cradleOptsProg = CradleAction: Cabal}
> Build profile: -w ghc-8.8.4 -O0
> In order, the following will be built (use -v for more details):
>  - pact-3.7 (test:hspec) (first run)
> Preprocessing test suite 'hspec' for pact-3.7..
2021-04-30 19:03:45.110849156 [ThreadId 346] INFO hls:	Using interface files cache dir: /home/tapas/.cache/ghcide/main-c5aeed3c2a1678cab0565680a4f4f9f919a921e5
2021-04-30 19:03:45.111137213 [ThreadId 346] INFO hls:	Using interface files cache dir: /home/tapas/.cache/ghcide/pact-3.7-inplace-a180612acf9c0a749f459cf6d98fb3b41cb90260
2021-04-30 19:03:45.111395534 [ThreadId 346] INFO hls:	Making new HscEnv[main,pact-3.7-inplace]
2021-04-30 19:03:45.355579071 [ThreadId 398] INFO hls:	Consulting the cradle for "HLint.hs"
2021-04-30 19:03:45.355655464 [ThreadId 398] WARNING hls:	No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for HLint.hs.
 Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
Output from setting up the cradle Cradle {cradleRootDir = "/home/tapas/haskell/pact", cradleOptsProg = CradleAction: Cabal}

Make Wrapper and Session loader use the same logic to avoid
loading logic divergence.

Cleans up existing usages to use infrastructure in place.
@fendor fendor force-pushed the fix/1782 branch 2 times, most recently from faebd77 to 3b34b92 Compare May 1, 2021 13:43
@fendor
Copy link
Collaborator Author

fendor commented May 1, 2021

Added a test as suggested by @jneira

Implements new major mode BiosMode that prints the cradle type and could be expanded in the future for more hie-bios commands.

I had troubles running the tests locally, let's see what CI says.

@fendor fendor force-pushed the fix/1782 branch 2 times, most recently from 565374a to 59297ea Compare May 1, 2021 16:41
Adds test-case for proving that wrapper and hls report the
same cradle type for a project.
@fendor
Copy link
Collaborator Author

fendor commented May 2, 2021

As per usual, you spend more time on trying to write tests than actually solving the issue.

I think this is ready for review

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great job @fendor, as usual
I hope the new cli option will be helpful beyond this concrete issue.

@pepeiborra pepeiborra added the merge me Label to trigger pull request merge label May 2, 2021
@mergify mergify bot merged commit 0da4168 into haskell:master May 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HLS Uses Wrong GHC for Stack Builds
5 participants