A typical haskell-language-server installation consists of:
- One binary file for each supported ghc version:
haskell-language-server-${ghcVersion} - Another binary named
haskell-language-version-wrapperwhich analyzes the project or file in the current working dir and calls the appropiatehaskell-language-server-${ghcVersion}variant.- It accepts all executable arguments from the plain
haskell-language-server
- It accepts all executable arguments from the plain
- For standalone
.hs/.lhsfiles, ghc must be installed and on the PATH. The easiest way to install it is with ghcup or chocolatey on Windows. - For Cabal based projects, both ghc and cabal-install must be installed and on the PATH. It can also be installed with ghcup or chocolatey on Windows.
- For Stack based projects, stack must be installed and on the PATH.
If you are using ghcup to manage your installations, you can install haskell-language-server with
ghcup install hlsYou can check if HLS is available for your platorm via ghcup here: https://haskell.org/ghcup/install/#supported-platforms.
You can also install HLS from source without checking out the code manually:
ghcup compile hls -v 1.6.1.0 --ghc 8.10.7Install HLS for multiple GHC versions:
ghcup compile hls -v 1.6.1.0 --ghc 8.10.7 --ghc 8.8.4
Use a different cabal.project for a GHC version:
ghcup compile hls -v 1.6.1.0 --ghc 9.2.1 --cabal-project cabal.project
Check ghcup compile hls --help for a full list of compilation options.
Direct installation from Source, while possible via cabal install haskell-language-server
and stack install --stack-yaml stack-<GHCVER>.yaml, is not recommended for most people.
Said command builds the haskell-language-server binary and installs it in the default Cabal binaries folder,
but the binary will only work with projects that use the same GHC version that built it.
stackorcabalmust be in your PATH- You need stack version >= 2.1.1 or cabal >= 2.4.0.0
gitmust be in your PATH- The directory where
stackorcabalput the binaries must be in you PATH:- For stack you can get it with
stack path --local-bin - For cabal it is by default
$HOME/.cabal/binin linux and%APPDATA%\cabal\binin windows.
- For stack you can get it with
Tip: you can quickly check if some command is in your path by running the command. If you receive some meaningful output instead of "command not found"-like message then it means you have the command in PATH.
On Linux you will need install a couple of extra libraries:
Debian 9/Ubuntu 18.04 or earlier:
sudo apt install libicu-dev libtinfo-dev libgmp-dev zlib1g-devDebian 10/Ubuntu 18.10 or later:
sudo apt install libicu-dev libncurses-dev libgmp-dev zlib1g-devFedora:
sudo dnf install libicu-devel ncurses-devel zlib-develGentoo
Haskell Language Server is available via the Haskell overlay. Follow the instructions here to install the overlay, then run:
emerge -av dev-util/haskell-language-serverDepending on your system setup, you may need to enable the unstable flag for this package before install, and possible also for the dependencies. If you enabled the ~testing versions as explained in the gentoo-haskell overlay instructions, then this won't be necessary.
In order to avoid problems with long paths on Windows you can do either one of the following:
-
Clone the
haskell-language-serverto a short path, for example the root of your logical drive (e.g. toC:\hls). Even if you chooseC:\haskell-language-serveryou could hit the problem. If this doesn't work or you want to use a longer path, try the second option. -
If the
Local Group Policy Editoris available on your system, go to:Local Computer Policy -> Computer Configuration -> Administrative Templates -> System -> FilesystemsetEnable Win32 long pathstoEnabled. If you don't have the policy editor you can use regedit by using the following instructions here. You also need to configure git to allow longer paths by using unicode paths. To set this for all your git repositories usegit config --system core.longpaths true(you probably need an administrative shell for this) or for just this one repository usegit config core.longpaths true.
In addition make sure haskell-language-server.exe is not running by closing your editor, otherwise in case of an upgrade the executable can not be installed.
git clone https://github.com/haskell/haskell-language-server
cd haskell-language-serverIf you are using chocolatey to manage your installations in windows, you can install haskell-language-server with
choco install haskell-language-serverIf you are using Visual Studio Code, the Haskell extension will automatically download and install haskell-language-server for you.
If you need to find the binaries, please consult the documentation for the extension.
There are pre-built binaries available from the releases page for Linux, Windows and macOS.
To install, download the haskell-language-server-wrapper executable for your platform as well as any haskell-language-server executables for the GHC versions you plan on working with, and either put them on your PATH or point your client to them.
The preferred method of installation for development purposes is to use the haskell-language-server-static package from AUR.
This package contains pre-built binaries for each supported GHC version and haskell-language-server-wrapper for automatic GHC version selection.
It is updated regularly, requires no additional dependencies, and is independent of other haskell packages you may have on your system, including GHC.
See ArchWiki for the details of Haskell infrastructure on Arch Linux.
Binary packages for Fedora are available from this Copr repo, built against the official Fedora ghc package.
HLS is available for installation from official binary packages. Use
pkg install hs-haskell-language-serverto install it. At the moment, HLS installed this way only supports the same GHC version as the ports one.
Direct installation from Hackage, while possible via cabal install haskell-language-server, is not recommended for most people.
Said command builds the haskell-language-server binary and installs it in the default Cabal binaries folder,
but the binary will only work with projects that use the same GHC version that built it.
The package can be found here on Hackage: https://hackage.haskell.org/package/haskell-language-server
Homebrew users can install haskell-language-server using the following command:
brew install haskell-language-serverThis formula contains HLS binaries compiled with GHC versions available via Homebrew; at the moment those are: 8.6.5, 8.8.4, 8.10.7.
You need to provide your own GHC/Cabal/Stack as required by your project, possibly via Homebrew.
You can read full instructions on how to install HLS with nix in haskell4nix documentation.