haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

StylishHaskell shifting the working dir, this could lead to race condition

Open soulomoon opened this issue 1 year ago • 7 comments

StylishHaskell shifting the working dir, it could make other part of hls depending on cwd result in error in some race condition.

https://github.com/haskell/haskell-language-server/blob/61fd5c464842448dfebe91d3e01de425eacf07b7/plugins/hls-stylish-haskell-plugin/src/Ide/Plugin/StylishHaskell.hs#L81

Such as Hlint, Stan, Template haskel, session loader etc. We should not shifting the working dir after initilization.

soulomoon avatar May 16 '24 09:05 soulomoon

#4231 Could alleviate the some potential race condition. But there are still a lot of place we could not clean up

soulomoon avatar May 16 '24 09:05 soulomoon

I am wondering if there is an alternaive function than loadConfig that does not depend on cwd to load the stylish config.

soulomoon avatar May 16 '24 13:05 soulomoon

We could ask upstream to expose a version that takes the directory as an argument.

michaelpj avatar May 17 '24 11:05 michaelpj

Yep, I've craete an issue there

soulomoon avatar May 17 '24 13:05 soulomoon

This is quite bad :sweat_smile: Perhaps we can copy-paste the loadConfig code from stylish-haskell and fix it ourselves until upstream fixed it?

fendor avatar Jun 26 '24 12:06 fendor

Seems like stylish's loadConfig already supports specifying directory as argument (Maybe FilePath). We just need to pass Just instead of Nothing, or am I missing something?

jhrcek avatar Jun 26 '24 12:06 jhrcek

Ok, the Maybe FilePath is the path to the stylish config file itselt, not to a "starting directory" as I imagined. So this will require some upstream changes after all :disappointed:

jhrcek avatar Jun 26 '24 13:06 jhrcek