zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.05k stars 2.96k forks source link

Zed does not obtain the haskell-language-server-wrapper binary from the current PATH when launched from CLI #16690

Open o1lo01ol1o opened 2 months ago

o1lo01ol1o commented 2 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

Using a PATH that contains a custom HLS wrapper (ie, a nix shell) and a GHC version not the same as whatever GHCUp has set, if you have it, you can confirm that HLS works:

$ 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 2.7.0.0 aarch64 ghc-9.4.8
Current directory: /Users/foo/bar
Operating system: darwin
Arguments: []
Cradle directory:  /Users/foo/bar
Cradle type: Cabal

Tool versions found on the $PATH
cabal:          3.10.2.1
stack:          2.15.3
ghc:            9.4.8

Then, confirm that it does not work with zed:

zed .

The Haskell extension will complain that it cannot determine the GHC used with this project, and, if you open a zed terminal and execute haskell-language-server-wrapper, it will indeed pick the wrong GHC for the project.

VSCode has a simple way to handle this:

in .vscode/setttings.json:

{
    "haskell.manageHLS": "PATH"
}

Environment

Darwin; zsh.

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log


o1lo01ol1o commented 2 months ago

... actually, if I configure an direnv .envrc file:

if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
  source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi

nix_direnv_watch_file flake.nix
nix_direnv_watch_file flake.lock

DEVENV_ROOT_FILE="$(mktemp)"
printf %s "$PWD" > "$DEVENV_ROOT_FILE"
if ! use flake . --override-input devenv-root "file+file://$DEVENV_ROOT_FILE"
then
  echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi

and open zed from the command line with zed . immediately after direnv sources the flake, zed seems to be able to find HLS sometimes.

srid commented 2 days ago

Given https://github.com/zed-industries/zed/issues/4977#issuecomment-2302406246 - I'd expect the following to work, yet it doesn't.

  "lsp": {
    "haskell": { "binary": { "path_lookup": true } }
  },