Closed bradrn closed 2 years ago
Hi, thanks for the bug report, could you post the module where you are trying to trigger retry (or the relevant pragmas for retrie)?
Could you also share a repro using VSCode?
@jneira It fails for every module I’ve tried.
(Also, it’s not just retrie either: all Wingman operations fail as well.)
@pepeiborra I don’t use VSCode regularly, but I’ll try to reproduce it.
@pepeiborra VSCode also gives me an error when I attempt to use Retrie or Wingman:
Thanks @bradrn but we need more details to reproduce. Project, steps, versions of hls, ghc, etc.
Project: this seems to happen for any project, even just plain Stack simple
template.
GHC version: again, this seems to be independent of GHC version from what I can tell.
HLS version:
> .\haskell-language-server-wrapper.exe --version
haskell-language-server version: 1.2.0.0 (GHC: 8.10.4) (PATH: C:\Users\bradn\Documents\Haskell\hls\haskell-language-server-wrapper.exe) (GIT hash: be2071e985cb417f984ab00a1aad76dee02d6d0b)
Can you attach a screen recording too please?
(EDIT: The uploaded video seems to have cut off all the relevant parts of my original recording. I’ll try to upload a better video.)
@pepeiborra Here’s a better recording:
As shown towards the end of the video most parts of HLS are working correctly; it is only retrie and parts of Wingman which are buggy.
hmm from the path of the call to hls in the cli it seems you are on windows, no?
Correct, I am on Windows 10.
ok, there is a existing issue about retrie and windows, although the symptoms are not the same afaics #533
Interesting… not sure if this is the same issue, but they certainly could be related. Do you know of any further tests I could try to diagnose this? (Though it’s getting late here and I don’t have time to do anything just right now.)
I just tried a retrie fold
and i am continue getting the same error as #533. Maybe your way to start emacs makes xargs
to be in scope? Your error would be triggered after avoiding that
Sorry, I’m not sure what you mean… are you saying that I should try removing xargs
from PATH, or I should add it to PATH?
no, no, I think maybe you already have xargs in scope and the error you are getting is the next one will try to reproduce yours
However wingman works correctly in my end
Logs for the wingman actions would be helpful as well. Thanks!
@isovector Sorry, which logs do you want? Because as far as I can tell the logs are the same for Retrie and Wingman — both give similar parse errors.
@bradrn maybe just the whole log!
Mmm, one thing that share retrie and wingman is ghc-exactprint usage iirc. No evidence to back the intuition though
Curiouser and curiouser. I tried to test the various code actions available to confirm what does and doesn’t work, ~and to my surprise I could not find a single Wingman command which failed~ (EDIT: found one, see next comment). ~I’m not sure why I reported that Wingman was failing, but whatever it was, it seems to be working perfectly now.~
On the other hand, Retrie is still not working, but it seems to give different errors depending on which command I use:
ExitFailure 1
.@isovector I tried collecting logs while testing, but I doubt you’ll be interested in all 70000+ lines! I’m not even sure where I would share a file of that size.
OK, now I’m thoroughly stumped. I decided to try Wingman in another project, and this time round it failed, with an absolutely bizarre error message:
LSP :: `workspace/executeCommand' with `1836:tactics:tacticsDestructLambdaCaseCommand' failed.
(error "C:\\sr\\ghc-8.10.4\\hyphenation-0.8.1-f8b6bb68cfad4b10e18172bc9e3eb5622f323a16\\share\\hyph-en-us.hyp.txt.gz: openBinaryFile: does not exist (No such file or directory)")
Any ideas?
Ugh, do you have the package installed in that location? D:\sr
seems the dir stack
sets as %STACK_ROOT%
by default when installed in windows, but ghc-8.10.4\\hyphenation-0.8.1-f8b6bb68cfad4b10e18172bc9e3eb5622f323a16
is the typical path cabal
uses to install packages with the v2-command. Maybe did you delete it?
@isovector I tried collecting logs while testing, but I doubt you’ll be interested in all 70000+ lines! I’m not even sure where I would share a file of that size.
I think all lines emitted by wingman would have the plugin name, maybe extracting them from the log while reproducing the error (they should not be so much) would help
Ugh, do you have the package installed in that location?
The path C:\sr\ghc-8.10.4
doesn’t even exist on my machine. I’m not sure where it’s coming from, unless it’s hardcoded in the source (which it surely wouldn’t be‽).
I think all lines emitted by wingman would have the plugin name, maybe extracting them from the log while reproducing the error (they should not be so much) would help
Good idea, I’ll try this.
The path C:\sr\ghc-8.10.4 doesn’t even exist on my machine. I’m not sure where it’s coming from, unless it’s hardcoded in the source (which it surely wouldn’t be‽).
very interesting, those paths could be hardcoded while assembling the executable (although they are not directly in the source code as you suspect), how did you got the hls executable? did the vscode extension download for you?
As mentioned already I’m using Emacs; the executables are simply downloaded from the GitHub releases page.
As mentioned already I’m using Emacs; the executables are simply downloaded from the GitHub releases page.
oh, right, vscode downloads the executable from the same location. To investigate. I will try to dust off my emacs installation in my windows 10 laptop if i have time.
You're running into https://github.com/haskell/haskell-language-server/issues/2015 on the Wingman side
Thanks @isovector!
I've been meaning to look into retrie on windows. My current thinking is that this is an escaping issues when passing backslash-based paths as stdin to xargs
Prelude System.Process> readCreateProcessWithExitCode (shell "xargs grep -l 'Var'") "C:/Users/name/Projects/natLog/library/Types.hs"
(ExitSuccess,"C:/Users/name/Projects/natLog/library/Types.hs\n","")
Prelude System.Process> readCreateProcessWithExitCode (shell "xargs grep -l 'Var'") "C:\\Users\\name\\Projects\\natLog\\library\\Types.hs"
(ExitFailure 123,"","grep: C:UsersnameProjectsnatLoglibraryTypes.hs: No such file or directory\n")
Something similar happens when running this in powershell, but weirdly not in cmd.exe .
This command is build when retrie tries to filter down a list of paths here.
This command eventually runs this function in System.Process so maybe the comment is related.
The quickest fix probably would be to substitute \ with / in the paths in the plugin.
@Tarmean wow, thanks for the further investigation, the fix could be convert the windows paths to unix style ones and does not seem to be too complex, would you be interested in make a pr?
The path conversion was really easy. Unfortunately the current System.Process implementation (well, hPutStr) also seems to mangle newlines in the stdin channel of the created process on windows by turning '\n' into '\r\n'. This also breaks xargs.
The stdin handle is created as 'intPtrToPtr (-1)' and I don't know enough about how this magic works to say how badly things would break if one were to call hSetNewlineMode.
An more palatable hack alternative might be to inline the first xargs invocation, i.e. turning
readCreateProcessWithExitCode (shell "xargs grep -l 'Fizz' | xargs grep -l 'Buzz'") paths
into
readCreateProcessWithExitCode (shell "grep -l 'Fizz' $paths | xargs grep -l 'Buzz'") ""
Either way I'm currently out of time so I will have to experiment more later.
Unfortunately the current System.Process implementation (well, hPutStr) also seems to mangle newlines in the stdin channel of the created process on windows by turning '\n' into '\r\n'.
I had to add a function to try to avoid that:
Replacing the usage of getTargetFiles with this version works on windows, the additions are filterChain0
and toUnixFilepath
.
This is a gist and not a pullrequest to retrie because I noticed a couple of oddities and want to double check they aren't my fault. I think the weirdness are existing bugs in retrie, though
'
aren't found because it generates searches like grep -L 'P''
foo []
doesn't fire if the occurrence is foo[]
, similar with superfluous bracketsHere is an example of weird operator behavior
{-# RULES "stepSum" forall x y. sum (x : y) = x + (sum y) #-}
foo :: Int
foo = sum (1 : 2 : 3 : [])
foo :: Int
foo = 1 : 2 : 3 + (sum [])
I think this was closed by #2513, @Tarmean thanks!
Cross-posted from https://github.com/emacs-lsp/lsp-haskell/issues/128 on the recommendation of @michaelpj:
And the relevant part of the log from LSP: