问题
What is the difference between adding package_name
under the build-depends:
section in a project's .cabal file
, versus doing stack install package_name
within that project's directory?
回答1:
stack install
will just install the package to the appropriate place (the current snapshot database for libraries in Stackage, the sandbox in ./.stack-work
for other libraries, ~/.local/bin
or your system's equivalent thereof for executables). Adding a library to build-depends
specifies it as a dependency of your project, and leads to the library being installed next time you do a stack build
. If you are actually using the library in your project you must add it to build-depends
, otherwise you won't be able to build the project (or even play with the library using stack ghci
).
N.B.: As of stack-0.1.3.1, stack install NAME
is just a synonym for stack build --copy-bins NAME
. The --copy-bins
option tells stack to copy any executables to ~/.local/bin
. If your package is just a library with no executables, stack install NAME
is the same as stack build NAME
.
来源:https://stackoverflow.com/questions/32303377/whats-the-difference-between-stack-install-name-and-name-in-the-build-depen