stack
The Haskell Tool Stack
https://github.com/commercialhaskell/stack
Version on this page: | 0.1.6.0@rev:6 |
LTS Haskell 23.21: | 3.1.1@rev:2 |
Stackage Nightly 2024-12-09: | 3.1.1@rev:2 |
Latest on Hackage: | 9.9.9@rev:4 |
stack-0.1.6.0@sha256:c9021f29f8e46134d9036fb8592edcfd31a0a0942dadcb4860b269f2aa463a34,11363
Module documentation for 0.1.6.0
- Data
- Data.Attoparsec
- Network
- Network.HTTP
- Network.HTTP.Download
- Network.HTTP
- Options
- Options.Applicative
- Options.Applicative.Args
- Options.Applicative.Builder
- Options.Applicative
- Path
- Stack
- Stack.Build
- Stack.BuildPlan
- Stack.Config
- Stack.Constants
- Stack.Docker
- Stack.Dot
- Stack.Exec
- Stack.Fetch
- Stack.FileWatch
- Stack.GhcPkg
- Stack.Ghci
- Stack.Ide
- Stack.Image
- Stack.Init
- Stack.New
- Stack.Options
- Stack.Package
- Stack.PackageDump
- Stack.PackageIndex
- Stack.SDist
- Stack.Setup
- Stack.Solver
- Stack.Types
- Stack.Types.Build
- Stack.Types.BuildPlan
- Stack.Types.Compiler
- Stack.Types.Config
- Stack.Types.Docker
- Stack.Types.FlagName
- Stack.Types.GhcPkgId
- Stack.Types.Image
- Stack.Types.Internal
- Stack.Types.Package
- Stack.Types.PackageIdentifier
- Stack.Types.PackageName
- Stack.Types.StackT
- Stack.Types.TemplateName
- Stack.Types.Version
- Stack.Upgrade
- Stack.Upload
- System
- System.Process
The Haskell Tool Stack
stack
is a cross-platform program for developing Haskell
projects. It is aimed at Haskellers both new and experienced.
It features:
- Installing GHC automatically, in an isolated location.
- Installing packages needed for your project.
- Building your project.
- Testing your project.
- Benchmarking your project.
How to install
Downloads are available by operating system:
Note: if you are using cabal-install to install stack, you may need to pass a
constraint to work around a
Cabal issue: cabal install --constraint 'mono-traversable >= 0.9' stack
.
Quick Start Guide
First you need to install it (see previous section).
Start your new project:
stack new my-project
cd my-project
stack setup
stack build
stack exec my-project-exe
- The
stack new
command will create a new directory containing all the needed files to start a project correctly. - The
stack setup
will download the compiler if necessary in an isolated location (default~/.stack
) that won’t interfere with any system-level installations. (For information on installation paths, please use thestack path
command.). - The
stack build
command will build the minimal project. stack exec my-project-exe
will execute the command.- If you just want to install an executable using stack, then all you have to do
is
stack install <package-name>
.
If you want to launch a REPL:
stack ghci
Run stack
for a complete list of commands.
Workflow
The stack new
command should have created the following files:
.
├── LICENSE
├── Setup.hs
├── app
│ └── Main.hs
├── my-project.cabal
├── src
│ └── Lib.hs
├── stack.yaml
└── test
└── Spec.hs
3 directories, 7 files
So to manage your library:
- Edit files in the
src/
directory.
The app
directory should preferably contains only files related to
executables.
-
If you need to include another library (for example the package
text
:- Add the package
text
to the filemy-project.cabal
in the sectionbuild-depends: ...
. - run
stack build
another time
- Add the package
-
If you get an error that tells you your package isn’t in the LTS. Just try to add a new version in the
stack.yaml
file in theextra-deps
section.
It was a really fast introduction on how to start to code in Haskell using stack
.
If you want to go further, we highly recommend you to read the stack
guide.
How to contribute
This assumes that you have already installed a version of stack, and have git
installed.
- Clone
stack
from git withgit clone https://github.com/commercialhaskell/stack.git
. - Enter into the stack folder with
cd stack
. - Build
stack
using a pre-existingstack
install withstack setup && stack build
. - Once
stack
finishes building, check the stack version withstack --version
. Make sure the version is the latest. - Look for issues tagged with
newcomer
andawaiting-pr
labels
Build from source as a one-liner:
git clone https://github.com/commercialhaskell/stack.git && \
cd stack && \
stack setup && \
stack build
Complete guide to stack
This repository also contains a complete user guide to using stack , covering all of the most common use cases.
Questions, Feedback, Discussion
- For frequently asked questions about detailed or specific use-cases, please see the FAQ.
- For general questions, comments, feedback and support please write to the stack mailing list.
- For bugs, issues, or requests please open an issue.
- When using Stack Overflow, please use the haskell-stack tag.
Why stack?
stack is a project of the Commercial Haskell group, spearheaded by FP Complete. It is designed to answer the needs of commercial Haskell users, hobbyist Haskellers, and individuals and companies thinking about starting to use Haskell. It is intended to be easy to use for newcomers, while providing the customizability and power experienced developers need.
While stack itself has been around since June of 2015, it is based on codebases used by FP Complete for its corporate customers and internally for years prior. stack is a refresh of that codebase combined with other open source efforts like stackage-cli to meet the needs of users everywhere.
A large impetus for the work on stack was a large survey of people interested in Haskell, which rated build issues as a major concern. The stack team hopes that stack can address these concerns.
Documentation Table Of Contents
- Project Documentation
- Maintainer Guide: includes releasing information
- Signing Key: downloadable stack binaries are signed with this key
- Tool Documentation
- Build Command: reference for the syntax of the build command and the command line targets
- Dependency Visualization: uses Graphviz
- Docker Integration
- FAQ: frequently asked questions about detailed or specific use-cases
- Install/Upgrade: a list of downloads available by operating system, installation instructions, and upgrade instructions
- Nonstandard Project Initialization
- Shell Autocompletion
- User Guide: in-depth tutorial covering the most common use cases and all major stack features (requires no prior Haskell tooling experience)
- YAML Configuration: reference for writing
stack.yaml
files
- Advanced Documentation
- Architecture: reference for people curious about stack internals, wanting to get involved deeply in the codebase, or wanting to use stack in unusual ways
Changes
Unreleased changes
v0.1.6.0
Major changes:
- “stack setup” now supports building and booting GHCJS from source tarball.
- On Windows, build directories no longer display “pretty” information (like x86_64-windows/Cabal-1.22.4.0), but rather a hash of that content. The reason is to avoid the 260 character path limitation on Windows. See #1027
- Rename config files and clarify their purposes #969
~/.stack/stack.yaml
–>~/.stack/config.yaml
~/.stack/global
–>~/.stack/global-project
/etc/stack/config
–>/etc/stack/config.yaml
- Old locations still supported, with deprecation warnings
- New command “stack eval CODE”, which evaluates to “stack exec ghc – -e CODE”.
Other enhancements:
- No longer install
git
on Windows #1046. You can still get this behavior by running the following yourself:stack exec -- pacman -Sy --noconfirm git
. - Typing enter during –file-watch triggers a rebuild #1023
- Use Haddock’s
--hyperlinked-source
(crosslinked source), if available #1070 - Use Stack-installed GHCs for
stack init --solver
#1072 - New experimental
stack query
command #1087 - By default, stack no longer rebuilds a package due to GHC options changes. This behavior can be tweaked with the
rebuild-ghc-options
setting. #1089 - By default, ghc-options are applied to all local packages, not just targets. This behavior can be tweaked with the
apply-ghc-options
setting. #1089 - Docker: download or override location of stack executable to re-run in container #974
- Docker: when Docker Engine is remote, don’t run containerized processes as host’s UID/GID #194
- Docker:
set-user
option to enable/disable running containerized processes as host’s UID/GID #194 - Custom Setup.hs files are now precompiled instead of interpreted. This should be a major performance win for certain edge cases (biggest example: building Cabal itself) while being either neutral or a minor slowdown for more common cases.
stack test --coverage
now also generates a unified coverage report for multiple test-suites / packages. In the unified report, test-suites can contribute to the coverage of other packages.
Bug fixes:
- Ignore stack-built executables named
ghc
#1052 - Fix quoting of output failed command line arguments
- Mark executable-only packages as installed when copied from cache #1043
- Canonicalize temporary directory paths #1047
- Put code page fix inside the build function itself #1066
- Add
explicit-setup-deps
option #1110, and change the default to the old behavior of using any package in the global and snapshot database #1025 - Precompiled cache checks full package IDs on Cabal < 1.22 #1103
- Pass -package-id to ghci #867
- Ignore global packages when copying precompiled packages #1146
0.1.5.0
Major changes:
- On Windows, we now use a full MSYS2 installation in place of the previous PortableGit. This gives you access to the pacman package manager for more easily installing libraries.
- Support for custom GHC binary distributions #530
ghc-variant
option in stack.yaml to specify the variant (also--ghc-variant
command-line option)setup-info
in stack.yaml, to specify where to download custom binary distributions (also--ghc-bindist
command-line option)- Note: On systems with libgmp4 (aka
libgmp.so.3
), such as CentOS 6, you may need to re-runstack setup
due to the centos6 GHC bindist being treated like a variant
- A new
--pvp-bounds
flag to the sdist and upload commands allows automatic adding of PVP upper and/or lower bounds to your dependencies
Other enhancements:
- Adapt to upcoming Cabal installed package identifier format change #851
stack setup
takes a--stack-setup-yaml
argument--file-watch
is more discerning about which files to rebuild for #912stack path
now supports--global-pkg-db
and--ghc-package-path
--reconfigure
flag #914 #946- Cached data is written with a checksum of its structure #889
- Fully removed
--optimizations
flag - Added
--cabal-verbose
flag - Added
--file-watch-poll
flag for polling instead of using filesystem events (useful for running tests in a Docker container while modifying code in the host environment. When code is injected into the container via a volume, the container won’t propagate filesystem events). - Give a preemptive error message when
-prof
is given as a GHC option #1015 - Locking is now optional, and will be turned on by setting the
STACK_LOCK
environment variable totrue
#950 - Create default stack.yaml with documentation comments and commented out options #226
- Out of memory warning if Cabal exits with -9 #947
Bug fixes:
- Hacky workaround for optparse-applicative issue with
stack exec --help
#806 - Build executables for local extra deps #920
- copyFile can’t handle directories #942
- Support for spaces in Haddock interface files fpco/minghc#85
- Temporarily building against a “shadowing” local package? #992
- Fix Setup.exe name for –upgrade-cabal on Windows #1002
- Unlisted dependencies no longer trigger extraneous second build #838
0.1.4.1
Fix stack’s own Haddocks. No changes to functionality (only comments updated).
0.1.4.0
Major changes:
- You now have more control over how GHC versions are matched, e.g. “use exactly this version,” “use the specified minor version, but allow patches,” or “use the given minor version or any later minor in the given major release.” The default has switched from allowing newer later minor versions to a specific minor version allowing patches. For more information, see #736 and #784.
- Support added for compiling with GHCJS
- stack can now reuse prebuilt binaries between snapshots. That means that, if you build package foo in LTS-3.1, that binary version can be reused in LTS-3.2, assuming it uses the same dependencies and flags. #878
Other enhancements:
- Added the
--docker-env
argument, to set environment variables in Docker container. - Set locale environment variables to UTF-8 encoding for builds to avoid “commitBuffer: invalid argument” errors from GHC #793
- Enable translitation for encoding on stdout and stderr #824
- By default,
stack upgrade
automatically installs GHC as necessary #797 - Added the
ghc-options
field to stack.yaml #796 - Added the
extra-path
field to stack.yaml - Code page changes on Windows only apply to the build command (and its synonyms), and can be controlled via a command line flag (still defaults to on) #757
- Implicitly add packages to extra-deps when a flag for them is set #807
- Use a precompiled Setup.hs for simple build types #801
- Set –enable-tests and –enable-benchmarks optimistically #805
--only-configure
option added #820- Check for duplicate local package names
- Stop nagging people that call
stack test
#845 --file-watch
will ignore files that are in your VCS boring/ignore files #703- Add
--numeric-version
option
Bug fixes:
stack init --solver
fails ifGHC_PACKAGE_PATH
is present #860stack solver
andstack init --solver
check for test suite and benchmark dependencies #862- More intelligent logic for setting UTF-8 locale environment variables #856
- Create missing directories for
stack sdist
- Don’t ignore .cabal files with extra periods #895
- Deprecate unused
--optimizations
flag - Truncated output on slow terminals #413
0.1.3.1
Bug fixes:
- Ignore disabled executables #763
0.1.3.0
Major changes:
- Detect when a module is compiled but not listed in the cabal file (#32)
- A warning is displayed for any modules that should be added to
other-modules
in the .cabal file - These modules are taken into account when determining whether a package needs to be built
- A warning is displayed for any modules that should be added to
- Respect TemplateHaskell addDependentFile dependency changes (#105)
- TH dependent files are taken into account when determining whether a package needs to be built.
- Overhauled target parsing, added
--test
and--bench
options #651- For details, see Build commands documentation
Other enhancements:
- Set the
HASKELL_DIST_DIR
environment variable #524 - Track build status of tests and benchmarks #525
--no-run-tests
#517- Targets outside of root dir don’t build #366
- Upper limit on number of flag combinations to test #543
- Fuzzy matching support to give better error messages for close version numbers #504
--local-bin-path
global option. Use to change where binaries get placed on a--copy-bins
#342- Custom snapshots #111
- –force-dirty flag: Force treating all local packages as having dirty files (useful for cases where stack can’t detect a file change)
- GHC error messages: display file paths as absolute instead of relative for better editor integration
- Add the
--copy-bins
option #569 - Give warnings on unexpected config keys #48
- Remove Docker
pass-host
option - Don’t require cabal-install to upload #313
- Generate indexes for all deps and all installed snapshot packages #143
- Provide
--resolver global
option #645- Also supports
--resolver nightly
,--resolver lts
, and--resolver lts-X
- Also supports
- Make
stack build --flag
error when flag or package is unknown #617 - Preserve file permissions when unpacking sources #666
stack build
etc work outside of a projectlist-dependencies
command #638--upgrade-cabal
option tostack setup
#174--exec
option #651--only-dependencies
implemented correctly #387
Bug fixes:
- Extensions from the
other-extensions
field no longer enabled by default #449 - Fix: haddock forces rebuild of empty packages #452
- Don’t copy over executables excluded by component selection #605
- Fix: stack fails on Windows with git package in stack.yaml and no git binary on path #712
- Fixed GHCi issue: Specifying explicit package versions (#678)
- Fixed GHCi issue: Specifying -odir and -hidir as .stack-work/odir (#529)
- Fixed GHCi issue: Specifying A instead of A.ext for modules (#498)
0.1.2.0
- Add
--prune
flag tostack dot
#487 - Add
--[no-]external
,--[no-]include-base
flags tostack dot
#437 - Add
--ignore-subdirs
flag to init command #435 - Handle attempt to use non-existing resolver #436
- Add
--force
flag toinit
command - exec style commands accept the
--package
option (see Reddit discussion) stack upload
without arguments doesn’t do anything #439- Print latest version of packages on conflicts #450
- Flag to avoid rerunning tests that haven’t changed #451
- stack can act as a script interpreter (see [Script interpreter] (https://github.com/commercialhaskell/stack/wiki/Script-interpreter) and Reddit discussion)
- Add the
--file-watch
flag to auto-rebuild on file changes #113 - Rename
stack docker exec
tostack exec --plain
- Add the
--skip-msys
flag #377 --keep-going
, turned on by default for tests and benchmarks #478concurrent-tests: BOOL
#492- Use hashes to check file dirtiness #502
- Install correct GHC build on systems with libgmp.so.3 #465
stack upgrade
checks version before upgrading #447
0.1.1.0
- Remove GHC uncompressed tar file after installation #376
- Put stackage snapshots JSON on S3 #380
- Specifying flags for multiple packages #335
- single test suite failure should show entire log #388
- valid-wanted is a confusing option name #386
- stack init in multi-package project should use local packages for dependency checking #384
- Display information on why a snapshot was rejected #381
- Give a reason for unregistering packages #389
stack exec
accepts the--no-ghc-package-path
parameter- Don’t require build plan to upload #400
- Specifying test components only builds/runs those tests #398
STACK_EXE
environment variable- Add the
stack dot
command stack upgrade
added #237--stack-yaml
command line flag #378--skip-ghc-check
command line flag #423
Bug fixes:
- Haddock links to global packages no longer broken on Windows #375
- Make flags case-insensitive #397
- Mark packages uninstalled before rebuilding #365
0.1.0.0
- Fall back to cabal dependency solver when a snapshot can’t be found
- Basic implementation of
stack new
#137 stack solver
command #364stack path
command #95- Haddocks #143:
- Build for dependencies
- Use relative links
- Generate module contents and index for all packages in project
0.0.3
--prefetch
#297upload
command ported from stackage-upload #225--only-snapshot
#310--resolver
#224stack init
#253--extra-include-dirs
and--extra-lib-dirs
#333- Specify intra-package target #201
0.0.2
- Fix some Windows specific bugs #216
- Improve output for package index updates #227
- Automatically update indices as necessary #227
- –verbose flag #217
- Remove packages (HTTPS and Git) #199
- Config values for system-ghc and install-ghc
- Merge
stack deps
functionality intostack build
install
command #153 and #272- overriding architecture value (useful to force 64-bit GHC on Windows, for example)
- Overhauled test running (allows cycles, avoids unnecessary recompilation, etc)
0.0.1
- First public release, beta quality