Install the toolchain with GHCup

Contents
Linux and macOS
Windows
Pin a compiler version
Check the install

Linux and macOS

GHCup is one shell script that downloads a compiler, a package manager, and a version switcher. It writes everything into ~/.ghcup and never touches system packages.

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

The installer asks three questions. Answer P to prepend the GHCup environment to your shell profile, N to skip the language server for now, and N to skip the Stack install. Then reload the shell:

source ~/.ghcup/env

On a fresh machine the script may need a C compiler (gcc) and the ncurses headers. On Debian and Ubuntu the packages are build-essential, libgmp-dev and libncurses-dev; on Fedora they are gcc, gmp-devel and ncurses-devel.

Windows

Run the same installer from PowerShell. It needs no administrator rights and no Visual Studio:

Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-WebRequest https://get-ghcup.haskell.org -UseBasicParsing | Invoke-Expression

Windows builds of GHC ship as MSYS2 packages, and GHCup installs a private MSYS2 under %APPDATA%. Keep the default answer when the installer offers to do that.

Pin a compiler version

GHCup installs the recommended compiler, but a project can need an older one. Install and select any version explicitly:

ghcup install ghc 9.10.1

ghcup set ghc 9.10.1

ghcup list

The last command prints a table with one row per version and a marker on the active one. Switching back is the same ghcup set call with another number, so two projects with different compilers never fight.

Check the install

Three version checks tell you whether the path is wired correctly. All of them must answer without a command not found message:

ghc --version

ghci --version

cabal --version

cabal-install version 3.12.1.0 compiled using version 3.12.1.0 of the Cabal library

If ghc works but a new terminal forgets it, the shell profile line is missing. Add source ~/.ghcup/env to ~/.bashrc or ~/.zshrc and open a new window.

Next: GHCi: the interactive shell

Article author: Arthur Isaev

Related articles
Haskell
Haskell course: zero to hero in 50 lessons
What is Haskell and why it matters
Install the toolchain with GHCup
GHCi: the interactive shell
Your first program
Values with let and where
Types and type signatures
Functions and application
Currying and partial application
Operators, sections, and fixity
if, guards, and pattern guards
case expressions
Pattern matching
Tuples
Lists
Ranges and enumeration
List comprehensions
Recursion replaces loops
map, filter, and foldr
Lambdas and composition
Type classes
Parametric polymorphism
Maybe and null safety
Either and recoverable errors
data: product types
data: sum types
Records
newtype and type synonyms
Recursive data: binary trees
Functor
Applicative
Monad
do notation
IO and purity
Files and IO
Modules and imports
Cabal projects
Dependencies
Testing with HUnit
Property testing with QuickCheck
Laziness and infinite lists
Strictness and space leaks
Folds
Monoids
Traversable
Monad transformers
Errors and exceptions
Concurrency
Parsing with Megaparsec
Capstone: a todo CLI
Hero roadmap: the whole course on one page

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: