It's my understanding (1) that the build-depends
section in my project's .cabal
file will ensure packages specified there are present in the resolver specified in stack.yml
are available (in the appropriate versions) and used when I test or run my package (e.g., with stack ghci
or stack test
, etc.).
I also gather (2) that the extra-deps
section of my stack.yml
is used to acquire packages that are not in the specified resolver.
But I'm confused about the role of
stack build some-package
How does this differ from extra-deps
? Will some-package
be used when I stack test
or stack ghci
etc.? Why use it instead of just adding some-package
to extra-deps
? (And, have I got (1) and (2) right?)
The main purpose of the
build
command is to actually trigger the build, i.e. compilation. By defaultstack build
will build all the "local" packages listed in thestack.yaml
'spackages
section. If you pass a package name as an argument tobuild
, that has usually one of the following two purposes:hlint
. Typically you will do this withstack install PKG
which is a shortcut forstack build --copy-bins PKG
.One core design principle of stack is that builds should be reproducible, i.e. a project with the same code and same configuration should always give the same result for
stack build
.That means that
stack build
orstack install
will never change the project configuration or add dependencies to the project.For more details on the
build
command, take a look at the relevant docs.