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

feat(hie-bios): Multi-cradle, ignore directories #147

Merged
merged 2 commits into from
Jun 12, 2020

Conversation

sir4ur0n
Copy link
Collaborator

@sir4ur0n sir4ur0n commented Jun 4, 2020

  • Rework hie.yaml templates (exclude some directories like testdata)
  • Add stack.yaml to install/ folder
  • Add Stack and Cabal templates for hie.yaml for install/ folder
  • Add and cleanup documentation about hie.yaml
  • Add comment about building for Stack

Closes #121
Closes #145

Note: Because my personal computer runs on Windows + WSL1 + there is a bug with WSL1 + Cabal, I can't test the Cabal flavor.
If anybody would be kind enough to give it a try, I would appreciate 😄

* Add stack.yaml to install/ folder
* Add Stack and Cabal templates for hie.yaml for install/ folder
* Add and cleanup documentation about hie.yaml
* Add comment about building for Stack
@sir4ur0n sir4ur0n force-pushed the feat/multiCradleHieTemplates branch from d6c69a4 to 27d3557 Compare June 5, 2020 22:36
@jneira jneira self-requested a review June 6, 2020 10:57
@jneira
Copy link
Member

jneira commented Jun 6, 2020

I've test the changes and i have to say that i was wrong about the none cradle: it is not supported by ghcide yet (see https://github.com/digital-asset/ghcide/issues/258). Testing it in with hls in cli mode confirms that, cause it still tries to load modules under testdata
We could keep it, as it would be the correct cradle but adding a comment about or remove it.
Sorry for the incoveniences.

EDIT: i've tested it again in a simple stack project with ghcide and hls and it seems to work, @sir4ur0n does it work for you with hls, on hls itself?

@sir4ur0n
Copy link
Collaborator Author

sir4ur0n commented Jun 7, 2020

@jneira I've gotta say I am confused by your message 😄 It works fine for me.

E.g. hovering on any function in the Completion module (in test/functional) works (displays the type) but hovering on any function in the CodeActionOnly (in test/testdata) doesn't do anything (no error, no hovering, etc.).

This looks exactly like the expected behavior to me 🤔

@jneira
Copy link
Member

jneira commented Jun 7, 2020

I was guessing that it works for you, but i wanted to confirm it cause i cant get it working for me (maybe it is a windows issue?)
Will try again later reinstalling hls

@@ -0,0 +1,13 @@
resolver: lts-14.27 # Last 8.6.5
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could use only one stack.yaml, removing shake.yaml?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it still wouldn't AFAIR there were inconsistencies with the Cabal dependency (not 100% sure though). But as long as there's a dependency on Shake, we can't do much...

Copy link
Member

@jneira jneira Jun 8, 2020

Choose a reason for hiding this comment

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

Mmm not sure what was the problem, but i've tried:

  • add
flags:
  hls-install:
    run-from-stack: true

to ./install/stack.yaml

  • remove ./install/shake.yaml
  • replace in ./install.hs,--stack-yaml=install/shake.yaml with --stack-yaml=install/stack.yaml

And both stack install.hs <target> and opening ./install/src/BuildSystem.hs seems to work fine.

Copy link
Member

@jneira jneira Jun 9, 2020

Choose a reason for hiding this comment

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

@sir4ur0n we could do the suggested change above in another pr if you prefer and merge this as is

Copy link
Member

@Ailrun Ailrun Jun 10, 2020

Choose a reason for hiding this comment

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

I'm not in hurry since I currently don't work with files under /install directory, and somehow managed HLS to work with itself in other directories, so please do whatever you are in favor of.

Copy link
Member

Choose a reason for hiding this comment

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

@Ailrun sorry, bad mention 😅

@jneira
Copy link
Member

jneira commented Jun 8, 2020

No luck, hls continue trying to load all files under ./testdata in cli mode and within the editor.
For example, opening ./test/testdata/addPackageTest/cabal-exe/AddPackage.hs the vscode output is:

[client] run command = "haskell-language-server-wrapper --lsp"
[client] debug command = "haskell-language-server-wrapper --lsp -d -l C:\TEMP\hls.log"
ghcide version: 0.1.0.0 (GHC: 8.10.1) (PATH: D:\bin\haskell-language-server-wrapper.exe)
ghcide version: 0.1.0.0 (GHC: 8.6.5) (PATH: D:\bin\haskell-language-server-8.6.5.exe)
Starting (haskell-language-server)LSP server...
  with arguments: Arguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsVersion = False, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "C:\\TEMP\\hls.log", argsThreads = 0}
  with plugins: [PluginId "brittany",PluginId "floskell",PluginId "ghcide",PluginId "ormolu",PluginId "pragmas"]
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.76s
Consulting the cradle for "D:\\dev\\ws\\haskell\\hls\\test\\testdata\\addPackageTest\\cabal-exe\\AddPackage.hs"
> �[0mUsing main module: 1. Package `testdata' component testdata:exe:filewithwarning with main-is file: D:\dev\ws\haskell\hls\test\testdata\FileWithWarning.hs�[0m
> �[0mBuilding all executables for `testdata' once. After a successful build of all of them, only specified executables will be rebuilt.�[0m
> �[0mtestdata> configure (exe)�[0m
> �[0mConfiguring testdata-0.1.0.0...�[0m
> �[0mThere exist several components with the same name: 'applyrefact2'. This is a bug in your .cabal file.�[0m
> �[0mCallStack (from HasCallStack):�[0m
> �[0m  error, called at libraries\Cabal\Cabal\Distribution\PackageDescription\Utils.hs:18:15 in Cabal-2.4.0.1:Distribution.PackageDescription.Utils�[0m
> �[0m
> �[91mError:�[0m 
> --  While building package testdata-0.1.0.0 using:
>       C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.5.exe --builddir=.stack-work\dist\e626a42b configure --user --package-db=clear --package-db=global --package-db=C:\sr\snapshots\abe6cda4\pkgdb --package-db=D:\dev\ws\haskell\hls\test\testdata\.stack-work\install\d90db3a0\pkgdb --libdir=D:\dev\ws\haskell\hls\test\testdata\.stack-work\install\d90db3a0\lib --bindir=D:\dev\ws\haskell\hls\test\testdata\.stack-work\install\d90db3a0\bin --datadir=D:\dev\ws\haskell\hls\test\testdata\.stack-work\install\d90db3a0\share --libexecdir=D:\dev\ws\haskell\hls\test\testdata\.stack-work\install\d90db3a0\libexec --sysconfdir=D:\dev\ws\haskell\hls\test\testdata\.stack-work\install\d90db3a0\etc --docdir=D:\dev\ws\haskell\hls\test\testdata\.stack-work\install\d90db3a0\doc\testdata-0.1.0.0 --htmldir=D:\dev\ws\haskell\hls\test\testdata\.stack-work\install\d90db3a0\doc\testdata-0.1.0.0 --haddockdir=D:\dev\ws\haskell\hls\test\testdata\.stack-work\install\d90db3a0\doc\testdata-0.1.0.0 --dependency=base=base-4.12.0.0 --dependency=parsec=parsec-3.1.14.0-8t8UKeFouAo5hdmomuIjPj --extra-include-dirs=D:\bin\stack\x86_64-windows\msys2-20180531\mingw64\include --extra-lib-dirs=D:\bin\stack\x86_64-windows\msys2-20180531\mingw64\lib --extra-lib-dirs=D:\bin\stack\x86_64-windows\msys2-20180531\mingw64\bin --exact-configuration --ghc-option=-fhide-source-paths
>     Process exited with code: ExitFailure 1�[0m
> �[0m
> �[33mWarning:�[0m Build failed, but trying to launch GHCi anyway�[0m
> �[0mConfiguring GHCi with the following packages: testdata�[0m
> �[0m
> �[33mWarning:�[0m Didn't find expected autogen file:
>          �[36mD:\dev\ws\haskell\hls\test\testdata\.stack-work\dist\e626a42b\build\filewithwarning\autogen\cabal_macros.h�[0m�[0m
> D:\dev\ws\haskell\hls\test\testdata\.stack-work\install\d90db3a0\pkgdb;C:\sr\snapshots\abe6cda4\pkgdb;D:\bin\stack\x86_64-windows\ghc-8.6.5\lib\package.conf.d
Right (ComponentOptions {componentOptions = ["-i","-odir=D:\\dev\\ws\\haskell\\hls\\test\\testdata\\.stack-work\\odir","-hidir=D:\\dev\\ws\\haskell\\hls\\test\\testdata\\.stack-work\\odir","-hide-all-packages","-iD:\\dev\\ws\\haskell\\hls\\test\\testdata\\.stack-work\\dist\\e626a42b\\build\\filewithwarning","-iD:\\dev\\ws\\haskell\\hls\\test\\testdata","-iD:\\dev\\ws\\haskell\\hls\\test\\testdata\\.stack-work\\dist\\e626a42b\\build\\filewithwarning\\autogen","-iD:\\dev\\ws\\haskell\\hls\\test\\testdata\\.stack-work\\dist\\e626a42b\\build\\global-autogen","-iD:\\dev\\ws\\haskell\\hls\\test\\testdata\\.stack-work\\dist\\e626a42b\\build\\filewithwarning\\filewithwarning-tmp","-stubdir=D:\\dev\\ws\\haskell\\hls\\test\\testdata\\.stack-work\\dist\\e626a42b\\build","-ID:\\bin\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\include","-LD:\\bin\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\lib","-LD:\\bin\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\bin","-package-id=base-4.12.0.0","-ghci-script=C:\\TEMP\\haskell-stack-ghci\\c10bf980\\ghci-script","-package-db","D:\\dev\\ws\\haskell\\hls\\test\\testdata\\.stack-work\\install\\d90db3a0\\pkgdb","-package-db","C:\\sr\\snapshots\\abe6cda4\\pkgdb","-package-db","D:\\bin\\stack\\x86_64-windows\\ghc-8.6.5\\lib\\package.conf.d"], componentRoot = "D:\\dev\\ws\\haskell\\hls\\test\\testdata", componentDependencies = ["testdata.cabal","package.yaml","stack.yaml"]})
"Making new HscEnv[main]"
Error while checking GHC version: "D:\\\\\\\\bin\\\\\\\\stack\\\\\\\\x86_64-windows\\\\\\\\ghc-8.6.5\\\\\\\\lib\\bin\\ghc: readCreateProcess: does not exist (No such file or directory)"
(([],Just HscEnvEq 4),fromList [("package.yaml",Nothing),("stack.yaml",Just 2020-06-07 21:23:06.0805727 UTC),("testdata.cabal",Nothing)])

But, well. the config itself is correct and we could investigate later why it does not work in my env

@sir4ur0n
Copy link
Collaborator Author

sir4ur0n commented Jun 8, 2020

Do you test with the Cabal or the Stack HIE file? I only test with Stack (in WSL1 as you already know).

Would be good to identify the discrepancy between your tests and mine.

That being said, if you're ok with this PR, we can also merge it and keep investigating in another issue.

The scenarii we know:

  • WSL1, Stack flavor: works
  • Windows, ??? flavor: fails

For what it's worth, my logs for opening the exact same file:

[client] run command = "haskell-language-server-wrapper --lsp"
[client] debug command = "haskell-language-server-wrapper --lsp"
ghcide version: 0.1.0.0 (GHC: 8.6.5) (PATH: /home/sir4ur0n/.local/bin/haskell-language-server-wrapper) (GIT hash: 2310e1039c90d9bccaffd688a0d1ec79a9360bf4)
ghcide version: 0.1.0.0 (GHC: 8.6.5) (PATH: /home/sir4ur0n/.local/bin/haskell-language-server-8.6.5) (GIT hash: 2310e1039c90d9bccaffd688a0d1ec79a9360bf4)
Starting (haskell-language-server)LSP server...
  with arguments: Arguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsVersion = False, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0}
  with plugins: [PluginId "brittany",PluginId "floskell",PluginId "ghcide",PluginId "ormolu",PluginId "pragmas"]
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.03s
2020-06-09 00:02:40.2330166 [ThreadId 34] - Opened text document: file:///home/sir4ur0n/code/haskell-language-server/test/testdata/CodeActionOnly.hs
Consulting the cradle for "/home/sir4ur0n/code/haskell-language-server/test/testdata/CodeActionOnly.hs"
Left []
2020-06-09 00:02:40.2496081 [ThreadId 93] - finish: FileStoreTC (took 0.01s)
2020-06-09 00:02:40.2525812 [ThreadId 138] - finish: CodeAction (took 0.00s)
2020-06-09 00:02:40.253015 [ThreadId 146] - finish: InitialLoad (took 0.00s)
2020-06-09 00:02:40.2535917 [ThreadId 175] - finish: CodeAction:PackageExports (took 0.00s)
2020-06-09 00:02:40.4932772 [ThreadId 179] - Plugin.makeCodeLens (ideLogger)
2020-06-09 00:18:54.7315856 [ThreadId 34] - Closed text document: file:///home/sir4ur0n/code/haskell-language-server/test/testdata/CodeActionOnly.hs
2020-06-09 00:18:54.7498367 [ThreadId 34] - Opened text document: file:///home/sir4ur0n/code/haskell-language-server/test/testdata/addPackageTest/cabal-exe/AddPackage.hs
Consulting the cradle for "/home/sir4ur0n/code/haskell-language-server/test/testdata/addPackageTest/cabal-exe/AddPackage.hs"
Left []
2020-06-09 00:18:54.7541819 [ThreadId 271] - finish: FileStoreTC (took 0.00s)
2020-06-09 00:18:54.7565094 [ThreadId 316] - finish: CodeAction (took 0.00s)
2020-06-09 00:18:54.7568878 [ThreadId 323] - finish: InitialLoad (took 0.00s)
2020-06-09 00:18:54.7574653 [ThreadId 352] - finish: CodeAction:PackageExports (took 0.00s)
2020-06-09 00:18:55.0019754 [ThreadId 395] - Plugin.makeCodeLens (ideLogger)
2020-06-09 00:18:57.6127853 [ThreadId 435] - GhcIde.hover entered (ideLogger)
2020-06-09 00:18:57.6183149 [ThreadId 435] - Hover request at position 2:11 in file: /home/sir4ur0n/code/haskell-language-server/test/testdata/addPackageTest/cabal-exe/AddPackage.hs
2020-06-09 00:18:57.9552627 [ThreadId 476] - GhcIde.hover entered (ideLogger)
2020-06-09 00:18:57.9561154 [ThreadId 476] - Hover request at position 3:11 in file: /home/sir4ur0n/code/haskell-language-server/test/testdata/addPackageTest/cabal-exe/AddPackage.hs

Note in particular:

2020-06-09 00:18:54.7498367 [ThreadId 34] - Opened text document: file:///home/sir4ur0n/code/haskell-language-server/test/testdata/addPackageTest/cabal-exe/AddPackage.hs
Consulting the cradle for "/home/sir4ur0n/code/haskell-language-server/test/testdata/addPackageTest/cabal-exe/AddPackage.hs"
Left []

@jneira
Copy link
Member

jneira commented Jun 8, 2020

Yeah, the weird thing is the none cradle works for other simple projects in my env so there is another factor i am not able to identify (yet). For a simple stack based project with a stack cradle i've got an output similar to yours.
But with hls it fails with both cabal and stack cradles. 🤔

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.

Ok, i am going forward and merge this one. I'll unify install/shake.yaml and install/stack.yaml in a new pr.

@jneira jneira merged commit 77dda30 into haskell:master Jun 12, 2020
@sir4ur0n sir4ur0n deleted the feat/multiCradleHieTemplates branch June 14, 2020 12:49
pepeiborra pushed a commit that referenced this pull request Dec 27, 2020
These tests document and monitor the evolution of the capabilities
announced by the server in the initialize response.

Currently the server advertises almost no capabilities. Out of 23
top-level categories, the only 3 which are announced are

+ text document sync
+ hover
+ goto definition

At the very least code actions are known to be provided, but are not
announced in the initialize response.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants