Skip to content

Commit f2aaa30

Browse files
committed
Fix #6068 Add stack install example
1 parent f6f092c commit f2aaa30

File tree

1 file changed

+58
-9
lines changed

1 file changed

+58
-9
lines changed

doc/build_command.md

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -543,16 +543,30 @@ input channel, an exception will be thown.
543543

544544
## Examples
545545

546-
* `stack build --test --copy-bins` or, equivalently, `stack test --copy-bins`
547-
or `stack install --test`, will build libraries, executables, and test
548-
suites, run the test suites, and then copy the executables to Stack's local
549-
binary directory (see `stack path --local-bin`). This is an example of the
550-
flags composing.
546+
All the following examples assume that:
551547

552-
* The following example uses the
553-
`wai` [repository](https://github.com/yesodweb/wai/)). The `wai` project
554-
comprises a number of packages, including `wai-extra` and `warp`. The
555-
command:
548+
* if `stack build` is commanded outside of a project directory, there is no
549+
`stack.yaml` file in the current directory or ancestor directory and,
550+
consequently, the project-level configuration will be determined by a
551+
`stack.yaml` file in the `global-project` directory in the Stack root (for
552+
further information, see the [YAML configuration](yaml_configuration.md)
553+
documentation); and
554+
555+
* if `stack build` is commanded in a project directory, there is a
556+
`stack.yaml` file in that directory.
557+
558+
Examples:
559+
560+
* In the project directory, `stack build --test --copy-bins` or, equivalently,
561+
`stack test --copy-bins` or `stack install --test`, will build libraries,
562+
executables, and test suites, run the test suites, and then copy the
563+
executables to Stack's local binary directory (see
564+
`stack path --local-bin`). This is an example of the flags composing.
565+
566+
* The following example uses a clone of the
567+
`wai` [repository](https://github.com/yesodweb/wai/). The `wai` project
568+
comprises a number of packages, including `wai-extra` and `warp`. In the
569+
`wai` project directory, the command:
556570

557571
~~~text
558572
stack build --file-watch --test --copy-bins --haddock wai-extra :warp warp:doctest --exec 'echo Yay, it worked!'
@@ -571,3 +585,38 @@ input channel, an exception will be thown.
571585
* Copy generated executables to Stack's local binary directory (see
572586
`stack path --local-bin`)
573587
* Run the command `echo Yay, it worked!`
588+
589+
* The following example uses the `Adga` package and assumes that `Adga-2.6.3`
590+
is the latest version in the package index (e.g. Hackage) and is not a
591+
version in the snapshot specified by the `stack.yaml` in the
592+
`global-project` directory in the Stack root.
593+
594+
Outside a project directory, `stack build Adga-2.6.3 --copy-bins` or,
595+
equivalently, `stack install Agda-2.6.3`, will attempt to build the
596+
libraries and executables of the identified version of the package in the
597+
package index (using the `stack.yaml` file in the `global-project`
598+
directory in the Stack root), and then copy the executables to Stack's local
599+
binary directory (see `stack path --local-bin`).
600+
601+
If a different snapshot is required to build the identified version of the
602+
package, then that can be specified at the command line. For example, to use
603+
the most recent Stackage Nightly snapshot:
604+
605+
~~~text
606+
stack --resolver nightly install Agda-2.6.3
607+
~~~
608+
609+
Alternatively, Stack can be used to unpack the package from the package
610+
index into a local project directory named after the package identifier (for
611+
further infomation, see the [`stack unpack` command](unpack_command.md)
612+
documentation) and, if the package does not provide its own Stack
613+
configuration file (`stack.yaml`), to attempt to initialise that
614+
configuration (for further information, see the
615+
[`stack init` command](init_command.md) documentation). For example:
616+
617+
~~~text
618+
stack unpack Agda-2.6.3
619+
cd Agda-2.6.3 # Change to the project directory
620+
stack init # Attempt to create a project stack.yaml file
621+
stack install # Equivalent to stack build --copy-bins
622+
~~~

0 commit comments

Comments
 (0)