oraios/serena · error · RuntimeError

haskell-language-server-wrapper is not installed or not in P

Error message

haskell-language-server-wrapper is not installed or not in PATH.
Searched locations:
  - {p}
Please install HLS via:
  - GHCup: https://www.haskell.org/ghcup/
  - Stack: stack install haskell-language-server
  - Cabal: cabal install haskell-language-server
  - Homebrew (macOS): brew install haskell-language-server

What it means

RuntimeError raised by HaskellLanguageServer._ensure_hls_installed when the haskell-language-server-wrapper executable cannot be found. The server searches PATH plus well-known locations (GHCup, Stack programs directories) and lists every location it checked. HLS is not auto-installed by the library.

Source

Thrown at src/solidlsp/language_servers/haskell_language_server.py:62

                for arch_dir in os.listdir(stack_programs):
                    arch_path = os.path.join(stack_programs, arch_dir)
                    if os.path.isdir(arch_path):
                        try:
                            for ghc_dir in os.listdir(arch_path):
                                hls_path = os.path.join(arch_path, ghc_dir, "bin", "haskell-language-server-wrapper")
                                if os.path.isfile(hls_path) and os.access(hls_path, os.X_OK):
                                    common_paths.append(hls_path)
                        except (PermissionError, OSError):
                            # Skip directories we can't read
                            continue
            except (PermissionError, OSError):
                # Stack programs directory not accessible
                pass

        for path in common_paths:
            if path and os.path.isfile(path) and os.access(path, os.X_OK):
                return path

        raise RuntimeError(
            "haskell-language-server-wrapper is not installed or not in PATH.\n"
            "Searched locations:\n" + "\n".join(f"  - {p}" for p in common_paths if p) + "\n"
            "Please install HLS via:\n"
            "  - GHCup: https://www.haskell.org/ghcup/\n"
            "  - Stack: stack install haskell-language-server\n"
            "  - Cabal: cabal install haskell-language-server\n"
            "  - Homebrew (macOS): brew install haskell-language-server"
        )

    def __init__(self, config: LanguageServerConfig, repository_root_path: str, solidlsp_settings: SolidLSPSettings):
        """
        Creates a HaskellLanguageServer instance. This class is not meant to be instantiated directly. Use LanguageServer.create() instead.
        """
        hls_executable_path = self._ensure_hls_installed()
        log.info(f"Using haskell-language-server at: {hls_executable_path}")

        # Check if there's a haskell subdirectory with Stack/Cabal project

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Install HLS via GHCup: `ghcup install hls` and `ghcup set hls latest`
  2. Ensure ~/.ghcup/bin is on PATH: export PATH="$HOME/.ghcup/bin:$PATH"
  3. Alternatively install with cabal (`cabal install haskell-language-server`) or stack (`stack install haskell-language-server`), and verify `haskell-language-server-wrapper --version`
  4. If installed elsewhere, point the server at the binary via ls_path configuration

Example fix

// before
haskell-language-server-wrapper --version  # not found
// after
ghcup install hls
export PATH="$HOME/.ghcup/bin:$PATH"
haskell-language-server-wrapper --version
Defensive patterns

Strategy: validation

Validate before calling

import os, shutil
def ensure_hls_installed():
    candidates = [shutil.which('haskell-language-server-wrapper'),
                  os.path.expanduser('~/.ghcup/bin/haskell-language-server-wrapper'),
                  os.path.expanduser('~/.local/bin/haskell-language-server-wrapper')]
    if not any(p and os.path.isfile(p) and os.access(p, os.X_OK) for p in candidates):
        raise FileNotFoundError('Install HLS: ghcup install hls')

Prevention

When it happens

Trigger: Constructing the Haskell language server when none of the candidate paths exist or are executable (os.path.isfile + os.access X_OK both required).

Common situations: HLS never installed; installed via GHCup but for a different GHC version or user; PATH missing ~/.ghcup/bin in daemon/CI context; Stack-installed HLS not in ~/.local/bin; non-executable file at a searched path.

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/64ef70623fac184c. Report an issue: GitHub.