Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using
getCurrentDirectory
andsetCurrentDirectory
makes it difficult to run tests in parallel since one thread modifying the globalCWD
variable would affect all other test threads. The goal of this PR is to deliberate on ways to avoid using the aforementioned functions (by making paths absolute) and have type guarantees for these absolute paths.Note [Root Directory] from Development.IDE.Core.Shake
We keep track of the root directory explicitly, which is the directory of the project root.
We might be setting it via these options with decreasing priority:
resRootPath
inLanguageContextEnv
.Using
getCurrentDirectory
makes it more difficult to run the tests, as we spawn one thread of HLS per test case.If we modify the global Variable CWD, via
setCurrentDirectory
, all other test threads are suddenly affected,forcing us to run all integration tests sequentially.
Also, there might be a race condition if we depend on the current directory, as some plugin might change it.
e.g. stylish's
loadConfig
. #4234But according to https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_workspaceFolders
The root dir is deprecated, that means we should cleanup dependency on the project root(Or $CWD) thing gradually,
so multi-workspaces can actually be supported when we use absolute path everywhere(might also need some high level design).
That might not be possible unless we have everything adapted to it, like 'hlint' and 'evaluation of template haskell'.
But we should still be working towards the goal.
We can drop it in the future once:
Thank you @fendor for mentioning haskell/cabal#9718 which seems to be doing something similar albeit for completely different reasons.
ref Path newtype declaration #4372
setCurrentDirectory
where possibleDetails
`doInitialize` uses the `defaultRoot` parameter, which is passed down from `setupLSP` (`argsProjectRoot`) in `Arguments{..}` in `defaultArguments` which seems to be taken from `getCurrentDirectory`.