Skip to content

Latest commit

 

History

History
166 lines (127 loc) · 7.01 KB

index.md

File metadata and controls

166 lines (127 loc) · 7.01 KB
title
Commands

Commands (advanced)

Some of Stack's features will not be needed regularly or by all users. This part of the guide and the part on configuration provide information about some of those features, organised as a reference guide. Some of the features are complex and separate pages are dedicated to them.

stack command

Stack is usually used with one of its commands (see further below). However:

  • stack, stack --help (or -h) lists Stack's commands, and flags and options common to those commands;

  • stack <command> --help (or -h) — provides help on the particular Stack command, including flags and options specific to the command; and

  • stack --version identifies the version and Git hash of the Stack executable.

!!! info "Runtime system (RTS) options"

The Stack executable is built by GHC with the `-rtsopts=some` option. This
means that the RTS extracts command-line arguments bracketed between `+RTS`
and `-RTS` as its own when Stack is run. Only the following RTS
options are available:

*   `-?` (e.g. `stack +RTS -?`) causes the RTS to output information about
    RTS options; and

*   `--info` (e.g. `stack +RTS --info`) causes the RTS to output information
    about the RTS.

To avoid the RTS extracting such command-line arguments as its own when
using Stack commands such as [`exec`](exec_command.md),
[`test`](test_command.md) or [`bench`](bench_command.md), see the
documentation for those commands.

Stack commands (thematic)

Setting up

  • setup - get GHC for a Stack project (usually not needed)
  • update - update the package index (usually not needed)
  • new - create a new project with Stack
  • init - initialise Stack's project-level YAML configuration file for an existing project

Building

  • build - build packages
  • test - a synonym for stack build --test
  • bench - a synonym for stack build --bench
  • haddock - a synonym for stack build --haddock
  • install - a synonym for stack build --copy-bins
  • run - build and run an executable

Docker-related

  • docker - use Stack with Docker

Executing in the Stack environment

  • exec - executate a command in the Stack environment
  • ghc - run ghc
  • eval - evaluate some Haskell code inline
  • runghc - run runghc
  • runhaskell - a synonym for stack runghc

Using GHC interactively

  • ghci - run GHCi, a REPL environment
  • repl - a synonym for stack ghci

Down/up loading local packages from/to Hackage

  • unpack - unpack one or more packages locally
  • sdist - create an archive file for a package, in a form accepted by Hackage
  • upload - upload a package to Hackage

Cleaning-up

  • clean - delete build artefacts for the project packages
  • purge - delete the Stack working directories

Amending Stack's configuration files

Using Haskell code as a script

  • script - run a Haskell source file as a script

Getting information

  • path - information about locations used by Stack
  • ls - list information about Stack
  • list - list packages on Hackage or in a snapshot
  • ide - information for an integrated development environment (IDE)
  • query - information about the build
  • config env - modify Stack's configuration
  • templates - information about templates for use with stack new
  • uninstall - information about how to uninstall Stack

Using tools in Stack's environment

  • hoogle - run hoogle
  • dot - dependency visualization
  • hpc - generate Haskell Program Coverage (HPC) code coverage reports

Managing Stack versions

Stack commands (alphabetical)

Stack's commands are listed below, in alphabetical order.

  • bench - a synonym for stack build --bench
  • build - build packages
  • clean - delete build artefacts for the project packages
  • config - access and modify Stack's configuration
  • docker - use Stack with Docker
  • dot - dependency visualization
  • eval - evaluate some Haskell code inline
  • exec - executate a command in the Stack environment
  • haddock - a synonym for stack build --haddock
  • hoogle - run hoogle
  • hpc - generate Haskell Program Coverage (HPC) code coverage reports
  • ghc - run ghc
  • ghci - run GHCi, a REPL environment
  • ide - information for an integrated development environment (IDE)
  • init - initialise Stack's project-level YAML configuration file for an existing project
  • install - a synonym for stack build --copy-bins
  • list - list packages on Hackage or in a snapshot
  • ls - list information about Stack
  • new - create a new project with Stack
  • path - information about locations used by Stack
  • purge - delete the Stack working directories
  • query - information about the build
  • repl - a synonym for stack ghci
  • run - build and run an executable
  • runghc - run runghc
  • runhaskell - a synonym for stack runghc
  • script - run a Haskell source file as a script
  • sdist - create an archive file for a package, in a form accepted by Hackage
  • setup - get GHC for a Stack project
  • templates - information about templates for use with stack new
  • test - a synonym for stack build --test
  • uninstall - information about how to uninstall Stack
  • unpack - unpack one or more packages locally
  • update - update the package index
  • upgrade - upgrade Stack
  • upload - upload a package to Hackage