upgrade - The Haskell Tool Stack (2024)

Install Stack

Stack can be installed on most Linux distributions, macOS and Windows. It willrequire at least about 5 GB of disk space, of which about 3 GB is for a singleversion of GHC and about 2 GB is for Stack's local copy of the Hackage packageindex.

Stack is open to supporting more operating systems. To request support for anoperating system, please submit anissue at Stack'sGitHub repository.

Info

In addition to the methods described below, Stack can also be installedusing the separate GHCup installer forHaskell-related tools. GHCup provides Stack for some combinations of machinearchitecture and operating system not provided elsewhere. Unlike Stack,other tools used for building Haskell code do not automatically install GHC.GHCup can be used to install GHC for those other tools. By default, thescript to install GHCup (which can be run more than once) also configuresStack so that if Stack needs a version of GHC, GHCup takes over obtainingand installing that version.

Releases on GitHub

Stack executables are also available on thereleases page ofStack's GitHub repository.

https://get.haskellstack.org/stable URLs

URLs with the formathttps://get.haskellstack.org/stable/<PLATFORM>.<EXTENSION> point to thelatest stable release. See the manual download links for examples.

sh script flags and options

The sh installation script recognises the following optional flags andoptions: -q suppresses output and specifies non-intervention (likely aprerequisite for the use of the script in CI environments); -f forces installation, even if an existing Stack executable is detected; and-d <directory> specifies a destination directory for the Stack executable.

For most Linux distributions, the easiest way to install Stack directly(rather than use GHCup) is to command:

curl -sSL https://get.haskellstack.org/ | sh

or:

wget -qO- https://get.haskellstack.org/ | sh

Note

The script at get.haskellstack.org willask for root access using sudo. It needs such access in order to useyour platform's package manager to install dependencies and to installto /usr/local/bin. If you prefer more control, follow the manualinstallation instructions for your platform below.

Manual download

Manual download for Linux distributions depends on your machinearchitecture, x86_64 or AArch64/ARM64.

  • Click to download an archive file with the latest release.

  • Extract the archive and place the stack executable somewhere on your PATH (see the Path section below).

  • Ensure you have the required system dependencies installed. These include GCC, GNU Make, xz, perl, libgmp, libffi, and zlib. We also recommend Git and GPG.

The installation of system dependencies will depend on the packagemanager for your Linux distribution. Notes are provided for Arch Linux,CentOS, Debian, Fedora, Gentoo and Ubuntu.

sudo pacman -S make gcc ncurses git gnupg xz zlib gmp libffi zlib
sudo yum install perl make automake gcc gmp-devel libffi zlib zlib-devel xz tar git gnupg
sudo apt-get install g++ gcc libc6-dev libffi-dev libgmp-dev make xz-utils zlib1g-dev git gnupg netbase
sudo dnf install perl make automake gcc gmp-devel libffi zlib zlib-devel xz tar git gnupg

Ensure you have the ncurses package with USE=tinfo. Without it,Stack will not be able to install GHC.

sudo apt-get install g++ gcc libc6-dev libffi-dev libgmp-dev make xz-utils zlib1g-dev git gnupg netbase
  • Click to download an archive file with the latest release.

  • Extract the archive and place the stack executable somewhere on your PATH (see the Path section below).

  • Ensure you have the required system dependencies installed. These include GCC, GNU Make, xz, perl, libgmp, libffi, and zlib. We also recommend Git and GPG.

The installation of system dependencies will depend on the packagemanager for your Linux distribution. Notes are provided for Arch Linux,CentOS, Debian, Fedora, Gentoo and Ubuntu.

sudo pacman -S make gcc ncurses git gnupg xz zlib gmp libffi zlib
sudo yum install perl make automake gcc gmp-devel libffi zlib zlib-devel xz tar git gnupg
sudo apt-get install g++ gcc libc6-dev libffi-dev libgmp-dev make xz-utils zlib1g-dev git gnupg netbase
sudo dnf install perl make automake gcc gmp-devel libffi zlib zlib-devel xz tar git gnupg

Ensure you have the ncurses package with USE=tinfo. Without it,Stack will not be able to install GHC.

sudo apt-get install g++ gcc libc6-dev libffi-dev libgmp-dev make xz-utils zlib1g-dev git gnupg netbase

Linux packages

Some Linux distributions have official or unofficial packages for Stack,including Arch Linux, Debian, Fedora, NixOS, openSUSE/SUSE Linux Enterprise,and Ubuntu. However, the Stack version available as a Linux package may lagbehind Stack's current version and, in some cases, the lag may besignificant.

Linux packages that lag behind Stack's current version

If Stack version available as a Linux package lags behind Stack'scurrent version, using stack upgrade --binary-only is recommendedafter installing it.

The Arch extra package repository provides an official x86_64package.You can install it with the command:

sudo pacman -S stack

The Arch User Repository (AUR) also provides:

There are Debianpackagesfor Buster and up. However, the distribution's Stack version lagsbehind.

Fedora includes Stack, but its Stack version may lag behind.

Users who follow the nixos-unstable channel or the Nixpkgs masterbranch can install the latest Stack release into their profile with thecommand:

nix-env -f "<nixpkgs>" -iA stack

Alternatively, the package can be built from source as follows.

  1. Clone the git repo, with the command:

    git clone https://github.com/commercialhaskell/stack.git
  2. Create a shell.nix file with the command:

    cabal2nix --shell ./. --no-check --no-haddock > shell.nix

    Note that the tests fail on NixOS, so disable them with--no-check. Also, Haddock currently doesn't work for Stack, so--no-haddock disables it.

  3. Install Stack to your user profile with the command:

    nix-env -i -f shell.nix

For more information on using Stack together with Nix, please see theNixOS manual section on Stack.

There is also an unofficial package for openSUSE or SUSE LinuxEnterprise. Its Stack version may lag behind. To install it:

sudo zypper in stack
sudo zypper ar http://download.opensuse.org/repositories/devel:/languages:/haskell/openSUSE_Leap_42.1/devel:languages:haskell.reposudo zypper in stack
sudo zypper ar http://download.opensuse.org/repositories/devel:/languages:/haskell/SLE_12/devel:languages:haskell.reposudo zypper in stack

There are Ubuntupackagesfor Ubuntu 20.04 and up.

It is possible to set up auto-completion of Stack commands. For furtherinformation, see the shell auto-completiondocumentation.

Most users of Stack on macOS will also have up to date tools for softwaredevelopment (see Xcode Command Line Toolsbelow).

From late 2020, Apple began a transition from Mac computers with Intelprocessors (Intel-based Mac) toMac computers with Apple silicon.

Intel-based Mac computers have processors with x86_64 architectures. Formost Intel-based Mac computers, the easiest way to install Stackdirectly (rather than use GHCup) is to command:

curl -sSL https://get.haskellstack.org/ | sh

or:

wget -qO- https://get.haskellstack.org/ | sh

Note

The script at get.haskellstack.orgwill ask for root access using sudo. It needs such access in orderto use your platform's package manager to install dependencies andto install to /usr/local/bin. If you prefer more control, followthe manual installation instructions below.

Info

We generally test on the current version of macOS and do our best tokeep it compatible with the three most recent major versions. Stackmay also work on older versions.

Manual download

  • Click to download an archive file with the latest release for x86_64 architectures.

  • Extract the archive and place stack somewhere on your PATH (see the Path section below).

  • Now you can run Stack from the command line in a terminal.

Mac computers with Apple silicon have an M1, M1 Pro, M1 Max, M1 Ultra orM2 chip. These chips use an architecture known as ARM64 or AArch64.

For Mac computers with Apple silicon, the easiest way to install Stackdirectly (rather than use GHCup) is to command:

curl -sSL https://get.haskellstack.org/ | sh

or:

wget -qO- https://get.haskellstack.org/ | sh

Note

The script at get.haskellstack.orgwill ask for root access using sudo. It needs such access in orderto use your platform's package manager to install dependencies andto install to /usr/local/bin. If you prefer more control, followthe manual installation instructions below.

The installation of Stack or some packages (e.g. network) requiring Csource compilation might fail with configure: error: C compiler cannotbuild executables. In that case you should pass -arch arm64 as partof the CFLAGS environment variable. This setting will be picked up bythe C compiler of your choice.

# Assuming BASH below# passing CFLAGS in-line with the command giving rise to the errorCFLAGS="-arch arm64 ${CFLAGS:-}" some_command_to_install_stackCFLAGS="-arch arm64 ${CFLAGS:-}" stack [build|install]# -- OR --# ~/.bash_profile# NOTE: only do this if you do not have to cross-compile, or remember to unset# CFLAGS when neededexport CFLAGS="-arch arm64 ${CFLAGS:-}"

The setting instructs the C compiler to compile objects for ARM64. Thesecan then be linked with libraries built for ARM64. Without theinstruction, the C compiler, invoked by Cabal running in x86-64, wouldcompile x86-64 objects and attempt to link them with existing ARM64libraries, resulting in the error above.

Manual download

  • Click to download an archive file with the latest release for AArch64 architectures.

  • Extract the archive and place stack somewhere on your PATH (see the Path section below).

  • Now you can run Stack from the command line in a terminal.

LLVM

The documentation for each version of GHC identifies the versions ofLLVM that are supported. That is summarised in the table below forrecent versions of GHC:

GHC versionLLVM versions
9.8.211 to 15
9.6.511 to 15
9.4.810 to 14
9.2.89 to 12
9.0.29, 10 or 12
8.10.79 to 12
8.8.47
8.6.56
8.4.45

Using Homebrew

Homebrew is a popular package manager for macOS. If youhave its brew tool installed, you can just command:

brew install haskell-stack
  • The Homebrew formula and bottles are unofficial and lag slightly behind new Stack releases, but tend to be updated within a day or two.

  • Normally, Homebrew will install from a pre-built binary (aka "pour from a bottle"), but if it starts trying to build everything from source (which will take hours), see their FAQ on the topic.

Xcode Command Line Tools

macOS does not come with all the tools required for software development buta collection of useful tools, known as the Xcode Command Line Tools, isreadily available. A version of that collection is provided with eachversion of Xcode (Apple’s integrated development environment) and can alsobe obtained from Apple separately from Xcode. The collection also includesthe macOS SDK (software development kit). The macOS SDK provides headerfiles for macOS APIs.

If you use a command that refers to a common Xcode Command Line Tool andthe Xcode Command Line Tools are not installed, macOS may prompt you toinstall the tools.

macOS also comes with a command line tool, xcode-select, that can be usedto obtain the Xcode Command Line Tools. Command xcode-select --print-pathto print the path to the currently selected (active) developer directory. Ifthe directory does not exist, or is empty, then the Xcode Command Line Toolsare not installed.

If the Xcode Command Line Tools are not installed, commandxcode-select --install to open a user interface dialog to requestautomatic installation of the tools.

An upgrade of macOS may sometimes require the existing Xcode Command LineTools to be uninstalled and an updated version of the tools to be installed.The existing tools can be uninstalled by deleting the directory reported byxcode-select --print-path.

If, after the installation of Stack, running stack setup fails withconfigure: error: cannot run C compiled programs. that indicates that theXcode Command Line Tools are not installed.

If building fails with messages that *.h files are not found, that mayalso indicate that Xcode Command Line Tools are not up to date.

Xcode 10 provided an SDK for macOS 10.14 (Mojave) andchanged the locationof the macOS system headers. As a workaround, an extra package was providedby Apple which installed the headers to the base system under/usr/include.

Auto-completion of Stack commands

It is possible to set up auto-completion of Stack commands. For furtherinformation, see the shell auto-completiondocumentation.

On 64-bit Windows, the easiest way to install Stack directly (rather thanuse GHCup) is to download and use theWindows installer.

Stack root

By default, the Windows installer will set the Stack root by setting theSTACK_ROOT environment variable to C:\sr.

Long user PATH environment variable

The Windows installer for Stack 2.9.1, 2.9.3 and 2.11.1 (only) willreplace the user PATH environment variable (rather than append to it)if a 1024 character limit is exceeded. If the content of your existinguser PATH is long, preserve it before running the installer.

Anti-virus software

Systems with antivirus software may need to add Stack to the list of'trusted' applications.

You may see a "Windows Defender SmartScreen prevented an unrecognizedapp from starting" warning when you try to run the installer. If so,click on More info, and then click on the Run anyway button thatappears.

We recommend installing to the default location with the installer, as thatwill make stack install and stack upgrade work correctly out of the box.

Manual download

  • Click to download an archive file with the latest release.

  • Unpack the archive and place stack.exe somewhere on your PATH (see the Path section below).

  • Now you can run Stack from the command line in a terminal.

Path

You can install Stack by copying the executable file anywhere on your PATH. Agood place to install is the same directory where Stack itself will installexecutables, which depends on the operating system:

Stack installs executables to:

$HOME/.local/bin

If you don't have that directory in your PATH, you may need to update yourPATH. That can be done by editing the ~/.bashrc file.

Stack installs executables to:

%APPDATA%\local\bin

For example: C:\Users\<user-name>\AppData\Roaming\local\bin.

If you don't have that directory in your PATH, you may need to update yourPATH. That can be done by searching for 'Edit Environment variables for youraccount' under Start.

Note

If you used GHCup to install Stack, GHCupputs executable files in the bin directory in the GHCup root directory.

China-based users

If you're attempting to install Stack from within China:

  • As of 24 February 2020, the download link has limited connectivity from within mainland China. If this is the case, please proceed by manually downloading (ideally via a VPN) and installing Stack per the instructions found on this page pertinent to your operating system.

  • After installation, your config.yaml file will need to be configured before Stack can download large files consistently from within China (without reliance on a VPN). Please add the following to the bottom of the config.yaml file:

###ADD THIS IF YOU LIVE IN CHINAsetup-info-locations:- "http://mirrors.tuna.tsinghua.edu.cn/stackage/stack-setup.yaml"urls: latest-snapshot: http://mirrors.tuna.tsinghua.edu.cn/stackage/snapshots.jsonpackage-indices:- download-prefix: http://mirrors.tuna.tsinghua.edu.cn/hackage/

Using an HTTP proxy

To use Stack behind a HTTP proxy with IP address IP and port PORT, first setup an environment variable http_proxy and then run the Stack command. Forexample:

export http_proxy=IP:PORTstack install

On most operating systems, it is not mandatory for programs to follow the"system-wide" HTTP proxy. Some programs, such as browsers, do honor this"system-wide" HTTP proxy setting, while other programs, including Bash, donot. That means configuring "http proxy setting" in your System Preferences(macOS) would not result in Stack traffic going through the proxy.

$Env:http_proxy=IP:PORTstack install

It is not mandatory for programs to follow the "system-wide" HTTP proxy.Some programs, such as browsers, do honor this "system-wide" HTTP proxysetting, while other programs do not. That means configuring"http proxy setting" in your Control Panel would not result in Stack trafficgoing through the proxy.

Upgrade Stack

There are different approaches to upgrading Stack, which vary as betweenUnix-like operating systems (including macOS) and Windows.

Note

If you used GHCup to install Stack, youshould also use GHCup to upgrade Stack. GHCup uses an executable namedstack to manage versions of Stack, through a file stack.shim. Stack willlikely overwrite the executable on upgrade.

There are essentially four different approaches:

  1. The stack upgrade command, which downloads a Stack executable, or builds it from source, and installs it to Stack's 'local-bin' directory (see stack path --local-bin). If different and permitted, it also installs a copy in the directory of the current Stack executable. (If copying is not permitted, copy stack from Stack's 'local-bin' directory to the system location afterward.) You can use stack upgrade to get the latest official release, and stack upgrade --git to install from GitHub and live on the bleeding edge. Make sure the location of the Stack executable is on the PATH. See the Path section above.

  2. If you're using a package manager and are happy with sticking with the officially released binaries from the distribution (which may the lag behind the latest version of Stack significantly), simply follow your normal package manager strategies for upgrading. For example:

    apt-get updateapt-get upgrade
  3. The get.haskellstack.org script supports the -f argument to over-write the current Stack executable. For example, command:

    curl -sSL https://get.haskellstack.org/ | sh -s - -f

    or:

    wget -qO- https://get.haskellstack.org/ | sh -s - -f
  4. Manually follow the steps above to download the newest executable from the GitHub releases page and replace the old executable.

There are essentially two different approaches:

  1. The stack upgrade command, which downloads a Stack executable, or builds it from source, and installs it to Stack's 'local-bin' directory (see stack path --local-bin). If different and permitted, it also installs a copy in the directory of the current Stack executable. (If copying is not permitted, copy stack from Stack's 'local-bin' directory to the system location afterward.) You can use stack upgrade to get the latest official release, and stack upgrade --git to install from GitHub and live on the bleeding edge. Make sure the location of the Stack executable is on the PATH. See the Path section above.

  2. Manually follow the steps above to download the newest executable from the GitHub releases page and replace the old executable.

Install earlier versions

To install a specific version of Stack, navigate to the desired version on theGitHub release page, andclick the appropriate link under its "Assets" drop-down menu.

Alternatively, use the URLhttps://github.com/commercialhaskell/stack/releases/download/vVERSION/stack-VERSION-PLATFORM.EXTENSION.For example, the tarball for Stack version 2.1.0.1, osx-x86_64 is athttps://github.com/commercialhaskell/stack/releases/download/v2.1.0.1/stack-2.1.0.1-osx-x86_64.tar.gz.

Here's a snippet for appveyor.yml files, borrowed from dhall'sappveyor.yml.Change the values of PATH and VERSION as needed.

install: - set PATH=C:\Program Files\Git\mingw64\bin;%PATH% - curl --silent --show-error --output stack.zip --location "https://github.com/commercialhaskell/stack/releases/download/v%STACK_VERSION%/stack-%STACK_VERSION%-windows-x86_64.zip" - 7z x stack.zip stack.exe - stack setup > nul - git submodule update --init --recursive
upgrade - The Haskell Tool Stack (2024)
Top Articles
Latest Posts
Article information

Author: Dr. Pierre Goyette

Last Updated:

Views: 5962

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Dr. Pierre Goyette

Birthday: 1998-01-29

Address: Apt. 611 3357 Yong Plain, West Audra, IL 70053

Phone: +5819954278378

Job: Construction Director

Hobby: Embroidery, Creative writing, Shopping, Driving, Stand-up comedy, Coffee roasting, Scrapbooking

Introduction: My name is Dr. Pierre Goyette, I am a enchanting, powerful, jolly, rich, graceful, colorful, zany person who loves writing and wants to share my knowledge and understanding with you.