Ignore invalid Unicode in pkg-config descriptions (#9609)
[cabal.git] / doc / cabal-commands.rst
blob229a5b7a616dab749257bcc5fbc3438e45060e45
1 Commands
2 ========
4 ``cabal help`` groups commands into :ref:`global<command-group-global>`,
5 :ref:`database<command-group-database>`, :ref:`init<command-group-init>`,
6 :ref:`configure<command-group-config>`, :ref:`build<command-group-build>`,
7 :ref:`run<command-group-run>` and :ref:`ship<command-group-ship>` sections.
9 ::
11     $ cabal help
12     Command line interface to the Haskell Cabal infrastructure.
14     See http://www.haskell.org/cabal/ for more information.
16     Usage: cabal [GLOBAL FLAGS] [COMMAND [FLAGS]]
18     Commands:
19      [global]
20       user-config            Display and update the user's global cabal configuration.
21       help                   Help about commands.
22       path                   Display paths used by cabal.
24      [package database]
25       update                 Updates list of known packages.
26       list                   List packages matching a search string.
27       info                   Display detailed information about a particular package.
29      [initialization and download]
30       init                   Create a new cabal package.
31       fetch                  Downloads packages for later installation.
32       get                    Download/Extract a package's source code (repository).
34      [project configuration]
35       configure              Add extra project configuration.
36       freeze                 Freeze dependencies.
37       gen-bounds             Generate dependency bounds.
38       outdated               Check for outdated dependencies.
40      [project building and installing]
41       build                  Compile targets within the project.
42       install                Install packages.
43       haddock                Build Haddock documentation.
44       haddock-project        Generate Haddocks HTML documentation for the cabal project.
45       clean                  Clean the package store and remove temporary files.
47      [running and testing]
48       list-bin               List the path to a single executable.
49       repl                   Open an interactive session for the given component.
50       run                    Run an executable.
51       bench                  Run benchmarks.
52       test                   Run test-suites.
53       exec                   Give a command access to the store.
55      [sanity checks and shipping]
56       check                  Check the package for common mistakes.
57       sdist                  Generate a source distribution file (.tar.gz).
58       upload                 Uploads source packages or documentation to Hackage.
59       report                 Upload build reports to a remote server.
61      [deprecated]
62       unpack                 Deprecated alias for 'get'.
63       hscolour               Generate HsColour colourised code, in HTML format.
65      [new-style projects (forwards-compatible aliases)]
66       Since cabal-install-3.0.0.0, all 'v2-' prefixed names of commands are just
67       aliases for the simple unprefixed names.  So v2-build is an alias for
68       build, v2-install for install and so on.
70      [legacy command aliases]
71       No legacy commands are described.
73 Common Arguments and Flags
74 --------------------------
76 Arguments and flags common to some or all commands are:
79 .. option:: --default-user-config=file
81     Allows a "default" ``cabal.config`` freeze file to be passed in
82     manually. This file will only be used if one does not exist in the
83     project directory already. Typically, this can be set from the
84     global cabal ``config`` file so as to provide a default set of
85     partial constraints to be used by projects, providing a way for
86     users to peg themselves to stable package collections.
89 .. option:: --allow-newer[=DEPS], --allow-older[=DEPS]
91     Selectively relax upper or lower bounds in dependencies without
92     editing the package description respectively.
94     The following description focuses on upper bounds and the
95     :option:`--allow-newer` flag, but applies analogously to
96     :option:`--allow-older` and lower bounds. :option:`--allow-newer`
97     and :option:`--allow-older` can be used at the same time.
99     If you want to install a package A that depends on B >= 1.0 && <
100     2.0, but you have the version 2.0 of B installed, you can compile A
101     against B 2.0 by using ``cabal install --allow-newer=B A``. This
102     works for the whole package index: if A also depends on C that in
103     turn depends on B < 2.0, C's dependency on B will be also relaxed.
105     Example:
107     ::
109         $ cd foo
110         $ cabal configure
111         Resolving dependencies...
112         cabal: Could not resolve dependencies:
113         [...]
114         $ cabal configure --allow-newer
115         Resolving dependencies...
116         Configuring foo...
118     Additional examples:
120     ::
122         # Relax upper bounds in all dependencies.
123         $ cabal install --allow-newer foo
125         # Relax upper bounds only in dependencies on bar, baz and quux.
126         $ cabal install --allow-newer=bar,baz,quux foo
128         # Relax the upper bound on bar and force bar==2.1.
129         $ cabal install --allow-newer=bar --constraint="bar==2.1" foo
131     It's also possible to limit the scope of :option:`--allow-newer` to single
132     packages with the ``--allow-newer=scope:dep`` syntax. This means
133     that the dependency on ``dep`` will be relaxed only for the package
134     ``scope``.
136     Example:
138     ::
140         # Relax upper bound in foo's dependency on base; also relax upper bound in
141         # every package's dependency on lens.
142         $ cabal install --allow-newer=foo:base,lens
144         # Relax upper bounds in foo's dependency on base and bar's dependency
145         # on time; also relax the upper bound in the dependency on lens specified by
146         # any package.
147         $ cabal install --allow-newer=foo:base,lens --allow-newer=bar:time
149     Finally, one can enable :option:`--allow-newer` permanently by setting
150     ``allow-newer: True`` in the :ref:`config file <config-file-discovery>`. Enabling
151     'allow-newer' selectively is also supported in the config file
152     (``allow-newer: foo, bar, baz:base``).
154 .. option:: --preference=CONSTRAINT
156     Specify a soft constraint on versions of a package. The solver will
157     attempt to satisfy these preferences on a "best-effort" basis.
159 .. option:: --enable-build-info
161     Generate accurate build information for build components.
163     Information contains meta information, such as component type, compiler type, and
164     Cabal library version used during the build, but also fine grained information,
165     such as dependencies, what modules are part of the component, etc...
167     On build, a file ``build-info.json`` (in the ``json`` format) will be written to
168     the root of the build directory.
170     .. note::
171         The format and fields of the generated build information is currently
172         experimental. In the future we might add or remove fields, depending
173         on the needs of other tooling.
175     .. code-block:: json
177         {
178             "cabal-lib-version": "<cabal lib version>",
179             "compiler": {
180                 "flavour": "<compiler name>",
181                 "compiler-id": "<compiler id>",
182                 "path": "<absolute path of the compiler>"
183             },
184             "components": [
185                 {
186                 "type": "<component type, e.g. lib | bench | exe | flib | test>",
187                 "name": "<component name>",
188                 "unit-id": "<unitid>",
189                 "compiler-args": [
190                     "<compiler args necessary for compilation>"
191                 ],
192                 "modules": [
193                     "<modules in this component>"
194                 ],
195                 "src-files": [
196                     "<source files relative to hs-src-dirs>"
197                 ],
198                 "hs-src-dirs": [
199                     "<source directories of this component>"
200                 ],
201                 "src-dir": "<root directory of this component>",
202                 "cabal-file": "<cabal file location>"
203                 }
204             ]
205         }
207     .. jsonschema:: ./json-schemas/build-info.schema.json
209 .. option:: --disable-build-info
211     (default) Do not generate detailed build information for built components.
213     Already generated `build-info.json` files will be removed since they would be stale otherwise.
215 Target Forms
216 ------------
218 A cabal command target can take any of the following forms:
220 -  A package target: ``[pkg:]package``, which specifies that all enabled
221    components of a package to be built. By default, test suites and
222    benchmarks are *not* enabled, unless they are explicitly requested
223    (e.g., via ``--enable-tests``.)
225 -  A component target: ``[package:][ctype:]component``, which specifies
226    a specific component (e.g., a library, executable, test suite or
227    benchmark) to be built.
229 -  All packages: ``all``, which specifies all packages within the project.
231 -  Components of a particular type: ``package:ctypes``, ``all:ctypes``:
232    which specifies all components of the given type. Where valid
233    ``ctypes`` are:
235      - ``libs``, ``libraries``,
236      - ``flibs``, ``foreign-libraries``,
237      - ``exes``, ``executables``,
238      - ``tests``,
239      - ``benches``, ``benchmarks``.
241 -  A module target: ``[package:][ctype:]module``, which specifies that the
242    component of which the given module is a part of will be built.
244 -  A filepath target: ``[package:][ctype:]filepath``, which specifies that the
245    component of which the given filepath is a part of will be built.
247 -  A script target: ``path/to/script``, which specifies the path to a script
248    file. This is supported by ``build``, ``repl``, ``run``, and ``clean``.
249    Script targets are not part of a package.
251 .. _command-group-global:
253 Global commands
254 ---------------
256 cabal user-config
257 ^^^^^^^^^^^^^^^^^
259 ``cabal user-config [init|diff|update]`` prints and updates user's global
260 cabal preferences. It is very useful when you are e.g. first configuring
261 ``cabal`` on a new machine.
263 - ``cabal user-config init`` creates a new configuration file.
265   .. option:: --config-file=PATH
267       Specify config file path. (default: ``~/.cabal/config``).
269   .. option:: -f, --force
271     Force configuration file overwriting if already exists.
273 - ``cabal user-config diff`` prints a diff of the user's config file and the
274   default one.
276 - ``cabal user-config update`` updates the user's config file with additional
277   lines.
279   .. option:: -a CONFIGLINE or -aCONFIGLINE, --augment=CONFIGLINE
281       Pass additional configuration lines to be incorporated in the
282       config file. e.g.
283       ``cabal user-config update --augment="offline: True"``.
285       Note how ``--augment`` syntax follows ``cabal user-config diff``
286       output.
288 cabal path
289 ^^^^^^^^^^
291 ``cabal path`` prints the file system paths used by ``cabal`` for
292 cache, store, installed binaries, and so on. When run without any
293 options, it will show all paths, labeled with how they are namen in
294 the configuration file:
297    $ cabal path
298    cache-dir: /home/haskell/.cache/cabal/packages
299    logs-dir: /home/haskell/.cache/cabal/logs
300    store-dir: /home/haskell/.local/state/cabal/store
301    config-file: /home/haskell/.config/cabal/config
302    installdir: /home/haskell/.local/bin
303    ...
305 If ``cabal path`` is passed a single option naming a path, then that
306 path will be printed *without* any label:
310    $ cabal path --installdir
311    /home/haskell/.local/bin
313 This is a stable interface and is intended to be used for scripting.
314 For example:
317    $ ls $(cabal path --installdir)
318    ...
320 .. _command-group-database:
322 Package database commands
323 -------------------------
325 cabal update
326 ^^^^^^^^^^^^
328 ``cabal update`` updates the state of the package index. If the
329 project contains multiple remote package repositories it will update
330 the index of all of them (e.g. when using overlays).
332 Some examples:
336     $ cabal update                  # update all remote repos
337     $ cabal update head.hackage     # update only head.hackage
339 cabal list
340 ^^^^^^^^^^
342 ``cabal list [FLAGS] STRINGS`` lists all packages matching a search string.
344 .. option::  --installed
346     Only output installed packages.
348 .. option::  --simple-output
350     Print matching packages in a one-package-one-line format.
352 .. option::  -i, --ignore-case
354 .. option::  -I, --strict-case
356 .. option:: --package-db=DB
358     Append the given package database to the list of used package
359     databases. See `cabal info`_ for a thorough explanation.
361 .. option:: -w PATH or -wPATH, --with-compiler=PATH
363     Path to specific compiler.
365 cabal info
366 ^^^^^^^^^^
368 ``cabal info [FLAGS] PACKAGES`` displays useful informations about remote
369 packages.
371 .. option:: --package-db=DB
373     Append the given package database to the list of package databases
374     used (to satisfy dependencies and register into). May be a specific
375     file, ``global`` or ``user``. The initial list is ``['global'], ['global',
376     'user']``, depending on context. Use ``clear`` to reset the list to empty.
378 .. _command-group-init:
380 Initialization and download
381 ---------------------------
383 cabal init
384 ^^^^^^^^^^
386 ``cabal init [FLAGS]`` initialises a Cabal package, picking
387 reasonable defaults. Run it in your project folder.
389 .. option:: -i, --interactive
391     Enable interactive mode.
393 .. option:: -m, --minimal
395     Generate a short .cabal file, without extra empty fields or
396     explanatory comments.
398 See :ref:`init quickstart` for an overview on the command, and
399 ``cabal init --help`` for the complete list of options.
401 cabal fetch
402 ^^^^^^^^^^^
404 *☞ N.B.:* ``cabal fetch`` only works for legacy ``v1-`` commands and only
405 for single package projects. If you are not maintaining an old project,
406 `cabal build`_ with ``--only-download`` has similar effects to ``fetch``
407 and benefits from compatibility with newer build methods.
409 ``cabal fetch [FLAGS] PACKAGES`` downloads packages for later installation.
410 It fetches the project plus its dependencies, very useful when
411 e.g. you plan to work on a project with unreliable or no internet access.
413 .. option:: --no-dependencies
415     Ignore dependencies.
417 .. option:: --disable-tests
419     Disable dependency checking and compilation
420     for test suites listed in the package
421     description file.
423 .. option::  --disable-benchmarks
425     Disable dependency checking and compilation
426     for benchmarks listed in the package
427     description file.
429 Check ``cabal fetch --help`` for a complete list of options.
431 cabal get
432 ^^^^^^^^^
434 ``cabal get [FLAGS] [PACKAGES]`` (synonym: ``cabal unpack``) downloads and unpacks
435 the source code of ``PACKAGES`` locally. By default the content of the
436 packages is unpacked in the current working directory, in named subfolders
437 (e.g.  ``./filepath-1.2.0.8/``), use ``--destdir=PATH`` to specify another
438 folder. By default the latest version of the package is downloaded, you can
439 ask for a spefic one by adding version numbers
440 (``cabal get random-1.0.0.1``).
442 The ``cabal get`` command supports the following options:
444 .. option:: -s[[head|this|...]], --source-repository[=[head|this|...]]
446     Clone the package's source repository (Darcs, Git, etc.)
447     instead of downloading the tarball. Only works if the
448     package specifies a ``source-repository``.
450 .. option:: --index-state=STATE
452     Pin your request to a specific Hackage index state. Available
453     ``STATE`` formats: Unix timestamps (e.g. ``@1474732068``),
454     ISO8601 UTC timestamps (e.g. ``2016-09-24T17:47:48Z``), or ``HEAD``
455     (default).
456     This determines which package versions are available as well as which
457     ``.cabal`` file revision is selected (unless ``--pristine`` is used).
459 .. option:: --pristine
461     Unpacks the pristine tarball, i.e. disregarding any Hackage revision.
463 .. option:: -d, --destdir=PATH
465     Where to place the package source, defaults to (a subdirectory of)
466     the current directory.
468 .. option:: --only-package-description, --package-description-only
470     Unpack the original pristine tarball, rather than updating the
471     ``.cabal`` file with the latest revision from the package archive.
474 .. _command-group-config:
476 Project configuration
477 ---------------------
479 cabal configure
480 ^^^^^^^^^^^^^^^
482 ``cabal configure`` takes a set of arguments and writes a
483 ``cabal.project.local`` file based on the flags passed to this command.
484 ``cabal configure FLAGS; cabal build`` is roughly equivalent to
485 ``cabal build FLAGS``, except that with ``configure`` the flags
486 are persisted to all subsequent calls to ``build``.
488 ``cabal configure`` is intended to be a convenient way to write out
489 a ``cabal.project.local`` for simple configurations; e.g.,
490 ``cabal configure -w ghc-7.8`` would ensure that all subsequent
491 builds with ``cabal build`` are performed with the compiler
492 ``ghc-7.8``. For more complex configuration, we recommend writing the
493 ``cabal.project.local`` file directly (or placing it in
494 ``cabal.project``!)
496 ``cabal configure`` inherits options from ``Cabal``. semantics:
498 -  Any flag accepted by ``./Setup configure``.
500 -  Any flag accepted by ``cabal configure`` beyond
501    ``./Setup configure``, namely ``--cabal-lib-version``,
502    ``--constraint``, ``--preference`` and ``--solver.``
504 -  Any flag accepted by ``cabal install`` beyond ``./Setup configure``.
506 -  Any flag accepted by ``./Setup haddock``.
508 The options of all of these flags apply only to *local* packages in a
509 project; this behavior is different than that of ``cabal install``,
510 which applies flags to every package that would be built. The motivation
511 for this is to avoid an innocuous addition to the flags of a package
512 resulting in a rebuild of every package in the store (which might need
513 to happen if a flag actually applied to every transitive dependency). To
514 apply options to an external package, use a ``package`` stanza in a
515 ``cabal.project`` file.
517 There are two ways of modifying the ``cabal.project.local`` file through
518 ``cabal configure``, either by appending new configurations to it, or
519 by simply overwriting it all. Overwriting is the default behaviour, as
520 such, there's a flag ``--enable-append`` to append the new configurations
521 instead. Since overwriting is rather destructive in nature, a backup system
522 is in place, which moves the old configuration to a ``cabal.project.local~``
523 file, this feature can also be disabled by using the ``--disable-backup``
524 flag.
526 cabal freeze
527 ^^^^^^^^^^^^
529 If a package is built in several different environments, such as a
530 development environment, a staging environment and a production
531 environment, it may be necessary or desirable to ensure that the same
532 dependency versions are selected in each environment. This can be done
533 with the ``freeze`` command:
535 ``cabal freeze`` writes out a **freeze file** which records all of
536 the versions and flags that are picked by the solver under the
537 current index and flags.  Default name of this file is
538 ``cabal.project.freeze`` but in combination with a
539 ``--project-file=my.project`` flag (see :ref:`project-file
540 <cmdoption-project-file>`)
541 the name will be ``my.project.freeze``.
542 A freeze file has the same syntax as ``cabal.project`` and looks
543 something like this:
545 .. highlight:: cabal
549     constraints: HTTP ==4000.3.3,
550                  HTTP +warp-tests -warn-as-error -network23 +network-uri -mtl1 -conduit10,
551                  QuickCheck ==2.9.1,
552                  QuickCheck +templatehaskell,
553                  -- etc...
556 For end-user executables, it is recommended that you distribute the
557 ``cabal.project.freeze`` file in your source repository so that all
558 users see a consistent set of dependencies. For libraries, this is not
559 recommended: users often need to build against different versions of
560 libraries than what you developed against.
562 cabal gen-bounds
563 ^^^^^^^^^^^^^^^^
565 ``cabal gen-bounds [FLAGS]`` generates bounds for all dependencies that do not
566 currently have them.  Generated bounds are printed to stdout. You can then
567 paste them into your .cabal file.
568 The generated bounds conform to the `Package Versioning Policy`_, which is
569 a recommended versioning system for publicly released Cabal packages.
571 .. code-block:: console
573     $ cabal gen-bounds
575 For example, given the following dependencies without bounds specified in
576 :pkg-field:`build-depends`:
580     build-depends:
581       base,
582       mtl,
583       transformers,
585 ``gen-bounds`` might suggest changing them to the following:
589     build-depends:
590       base          >= 4.15.0 && < 4.16,
591       mtl           >= 2.2.2 && < 2.3,
592       transformers  >= 0.5.6 && < 0.6,
595 cabal outdated
596 ^^^^^^^^^^^^^^
598 ``cabal outdated [FLAGS]`` checks for outdated dependencies in the package
599 description file or freeze file.
601 Manually updating dependency version bounds in a ``.cabal`` file or a
602 freeze file can be tedious, especially when there's a lot of
603 dependencies. The ``cabal outdated`` command is designed to help with
604 that. It will print a list of packages for which there is a new
605 version on Hackage that is outside the version bound specified in the
606 ``build-depends`` field. The ``outdated`` command can also be
607 configured to act on the freeze file and
608 ignore major (or all) version bumps on Hackage for a subset of
609 dependencies.
611 Examples:
613 .. code-block:: console
615     $ cd /some/package
616     $ cabal outdated
617     Outdated dependencies:
618     haskell-src-exts <1.17 (latest: 1.19.1)
619     language-javascript <0.6 (latest: 0.6.0.9)
620     unix ==2.7.2.0 (latest: 2.7.2.1)
622     $ cabal outdated --simple-output
623     haskell-src-exts
624     language-javascript
625     unix
627     $ cabal outdated --ignore=haskell-src-exts
628     Outdated dependencies:
629     language-javascript <0.6 (latest: 0.6.0.9)
630     unix ==2.7.2.0 (latest: 2.7.2.1)
632     $ cabal outdated --ignore=haskell-src-exts,language-javascript,unix
633     All dependencies are up to date.
635     $ cabal outdated --ignore=haskell-src-exts,language-javascript,unix -q
636     $ echo $?
637     0
639     $ cd /some/other/package
640     $ cabal outdated --freeze-file
641     Outdated dependencies:
642     HTTP ==4000.3.3 (latest: 4000.3.4)
643     HUnit ==1.3.1.1 (latest: 1.5.0.0)
645     $ cabal outdated --freeze-file --ignore=HTTP --minor=HUnit
646     Outdated dependencies:
647     HUnit ==1.3.1.1 (latest: 1.3.1.2)
650 ``cabal outdated`` supports the following flags:
652 .. option:: --freeze-file
654     Read dependency version bounds from the freeze file.
656     (``cabal.config``) instead of the package description file
657     (``$PACKAGENAME.cabal``).
659 .. option:: --v2-freeze-file
661     :since: 2.4
663     Read dependency version bounds from the v2-style freeze file
664     (by default, ``cabal.project.freeze``) instead of the package
665     description file. ``--new-freeze-file`` is an alias for this flag
666     that can be used with pre-2.4 ``cabal``.
668 .. option:: --project-file=FILE
670     :since: 2.4
672     Read dependency version bounds from the v2-style freeze file
673     related to the named project file (i.e., ``$PROJECTFILE.freeze``)
674     instead of the package description file. If multiple ``--project-file``
675     flags are provided, only the final one is considered. This flag
676     must only be passed in when ``--new-freeze-file`` is present.
678 .. option:: --simple-output
680     Print only the names of outdated dependencies, one per line.
682 .. option:: --exit-code
684     Exit with a non-zero exit code when there are outdated dependencies.
686 .. option:: -q, --quiet
688     Don't print any output. Implies ``-v0`` and ``--exit-code``.
690 .. option:: --ignore=PKGS
692     Don't warn about outdated dependency version bounds for the packages in this list.
694 .. option:: --minor[PKGS]
696     Ignore major version bumps for these packages.
698     E.g. if there's a version 2.0 of a package ``pkg`` on Hackage and the freeze
699     file specifies the constraint ``pkg == 1.9``, ``cabal outdated --freeze
700     --minor=pkg`` will only consider the ``pkg`` outdated when there's a version
701     of ``pkg`` on Hackage satisfying ``pkg > 1.9 && < 2.0``. ``--minor`` can also
702     be used without arguments, in that case major version bumps are ignored for
703     all packages.
705 .. _command-group-build:
707 Project building and installing
708 -------------------------------
710 cabal build
711 ^^^^^^^^^^^
713 ``cabal build`` takes a set of targets and builds them. It
714 automatically handles building and installing any dependencies of these
715 targets.
717 In component targets, ``package:`` and ``ctype:`` (valid component types
718 are ``lib``, ``flib``, ``exe``, ``test`` and ``bench``) can be used to
719 disambiguate when multiple packages define the same component, or the
720 same component name is used in a package (e.g., a package ``foo``
721 defines both an executable and library named ``foo``). We always prefer
722 interpreting a target as a package name rather than as a component name.
724 Some example targets:
728     $ cabal build lib:foo-pkg       # build the library named foo-pkg
729     $ cabal build foo-pkg:foo-tests # build foo-tests in foo-pkg
730     $ cabal build src/Lib.s         # build the library component to
731                                        # which "src/Lib.hs" belongs
732     $ cabal build app/Main.hs       # build the executable component of
733                                        # "app/Main.hs"
734     $ cabal build Lib               # build the library component to
735                                        # which the module "Lib" belongs
736     $ cabal build path/to/script    # build the script as an executable
738 Beyond a list of targets, ``cabal build`` accepts all the flags that
739 ``cabal configure`` takes. Most of these flags are only taken into
740 consideration when building local packages; however, some flags may
741 cause extra store packages to be built (for example,
742 ``--enable-profiling`` will automatically make sure profiling libraries
743 for all transitive dependencies are built and installed.)
745 When building a script, the executable is cached under the cabal directory.
746 See ``cabal run`` for more information on scripts.
748 In addition ``cabal build`` accepts these flags:
750 .. option:: --only-configure
752     When given we will forego performing a full build and abort after running
753     the configure phase of each target package.
755 cabal install
756 ^^^^^^^^^^^^^
758 ``cabal install [FLAGS] [TARGETS]`` builds the specified target packages and
759 symlinks/copies their executables in ``installdir`` (usually ``~/.local/bin``).
761 .. warning::
763   If not every package has an executable to install, use ``all:exes`` rather
764   than ``all`` as the target. To overwrite an installation, use
765   ``--overwrite-policy=always`` as the default policy is ``never``.
767 For example this command will build the latest ``cabal-install`` and symlink
768 its ``cabal`` executable:
772     $ cabal install cabal-install
774 In addition, it's possible to use ``cabal install`` to install components
775 of a local project. For example, with an up-to-date Git clone of the Cabal
776 repository, this command will build cabal-install HEAD and symlink the
777 ``cabal`` executable:
781     $ cabal install exe:cabal
783 Where symlinking is not possible (eg. on some Windows versions) the ``copy``
784 method is used by default. You can specify the install method
785 by using ``--install-method`` flag:
789     $ cabal install exe:cabal --install-method=copy --installdir=$HOME/bin
791 Note that copied executables are not self-contained, since they might use
792 data-files from the store.
794 .. _adding-libraries:
796 Adding libraries to GHC package environments
797 """"""""""""""""""""""""""""""""""""""""""""
799 It is also possible to "install" libraries using the ``--lib`` flag. For
800 example, this command will build the latest Cabal library and install it:
804     $ cabal install --lib Cabal
806 This works by managing GHC package environment files. By default, it is writing
807 to the global environment in ``~/.ghc/$ARCH-$OS-$GHCVER/environments/default``.
808 ``install`` provides the ``--package-env`` flag to control which of these
809 environments is modified.
811 This command will modify the environment file in the current directory:
815     $ cabal install --lib Cabal --package-env .
817 This command will modify the environment file in the ``~/foo`` directory:
821     $ cabal install --lib Cabal --package-env foo/
823 Do note that the results of the previous two commands will be overwritten by
824 the use of other style commands, so it is not recommended to use them inside
825 a project directory.
827 This command will modify the environment in the ``local.env`` file in the
828 current directory:
832     $ cabal install --lib Cabal --package-env local.env
834 This command will modify the ``myenv`` named global environment:
838     $ cabal install --lib Cabal --package-env myenv
840 If you wish to create a named environment file in the current directory where
841 the name does not contain an extension, you must reference it as ``./myenv``.
843 You can learn more about how to use these environments in `this section of the
844 GHC manual <https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/packages.html#package-environments>`_.
846 cabal haddock
847 ^^^^^^^^^^^^^
849 ``cabal haddock [FLAGS] [TARGET]`` builds Haddock documentation for
850 the specified packages within the project.
852 If a target is not a library :cfg-field:`haddock-benchmarks`,
853 :cfg-field:`haddock-executables`, :cfg-field:`haddock-internal`,
854 :cfg-field:`haddock-tests` will be implied as necessary.
856 cabal haddock-project
857 ^^^^^^^^^^^^^^^^^^^^^
859 ``cabal haddock-project [FLAGS]`` builds Haddock documentation for all local
860 packages specified in the project.
862 By default the documentation will be put in ``./haddocks`` folder, this can be
863 modified with the ``--output`` flag.
865 This command supports two primary modes: building a self contained directory
866 (which is the default mode) or documentation that links to hackage (with
867 ``--hackage`` flag).
869 In both cases the html index as well as quickjump index will include all terms
870 and types defined in any of the local packages, but not ones that are included
871 in any of the dependencies.  But note that if you navigate to a dependency,
872 you will have access to its quickjump index.
874 The generated landing page will contain one tree of all modules per local
875 package.
877 cabal clean
878 ^^^^^^^^^^^
880 ``cabal clean [FLAGS]`` cleans up the temporary files and build artifacts
881 stored in the ``dist-newstyle`` folder.
883 By default, it removes the entire folder, but it can also spare the configuration
884 and caches if the ``--save-config`` option is given, in which case it only removes
885 the build artefacts (``.hi``, ``.o`` along with any other temporary files generated
886 by the compiler, along with the build output).
888 ``cabal clean [FLAGS] path/to/script`` cleans up the temporary files and build
889 artifacts for the script, which are stored under the .cabal/script-builds directory.
891 In addition when clean is invoked it will remove all script build artifacts for
892 which the corresponding script no longer exists.
894 .. _command-group-run:
896 Running and testing
897 -------------------
899 cabal list-bin
900 ^^^^^^^^^^^^^^
902 ``cabal list-bin`` will either (a) display the path for a single executable or (b)
903 complain that the target doesn't resolve to a single binary. In the latter case,
904 it will name the binary products contained in the package. These products can
905 be used to narrow the search and get an actual path to a particular executable.
907 Example showing a failure to resolve to a single executable.
911     $ cabal list-bin cabal-install
912     cabal: The list-bin command is for finding a single binary at once. The
913     target 'cabal-install' refers to the package cabal-install-#.#.#.# which
914     includes the executable 'cabal', the test suite 'unit-tests', the test suite
915     'mem-use-tests', the test suite 'long-tests' and the test suite
916     'integration-tests2'.
918 For a scope that results in only one item we'll get a path.
922     $ cabal list-bin cabal-install:exes
923     /.../dist-newstyle/build/.../cabal/cabal
925     $ cabal list-bin cabal-install:cabal
926     /.../dist-newstyle/build/.../cabal/cabal
928 We can also scope to test suite targets as they produce binaries.
932     $ cabal list-bin cabal-install:tests
933     cabal: The list-bin command is for finding a single binary at once. The
934     target 'cabal-install:tests' refers to the test suites in the package
935     cabal-install-#.#.#.# which includes the test suite 'unit-tests', the test
936     suite 'mem-use-tests', the test suite 'long-tests' and the test suite
937     'integration-tests2'.
939     $ cabal list-bin cabal-install:unit-tests
940     /.../dist-newstyle/.../unit-tests/unit-tests
942 Note that ``cabal list-bin`` will print the executables' location, but
943 will not make sure that these executables actually exist (i.e., have
944 been successfully built).  In order to determine the correct location,
945 it may invoke the configuration step (see ``cabal configure``).
947 cabal repl
948 ^^^^^^^^^^
950 ``cabal repl TARGET [FLAGS]``
951 opens an interactive session for the target component within the project and
952 loads all of the modules of the target into GHCi as interpreted bytecode.
953 The available targets are the same as for the ``build`` command: individual components
954 within packages in the project, including libraries, executables, test-suites
955 and benchmarks (see `the build section <#cabal-build>`__ for the target syntax).
956 Local packages can also be specified, in which case the library
957 component in the package will be used, or the (first listed) executable in the
958 package if there is no library. Dependencies are built or rebuilt as necessary.
960 Examples:
964     $ cabal repl                # default component in the package in the current directory
965     $ cabal repl pkgname        # default component in the package named 'pkgname'
966     $ cabal repl ./pkgfoo       # default component in the package in the ./pkgfoo directory
967     $ cabal repl cname          # component named 'cname'
968     $ cabal repl pkgname:cname  # component 'cname' in the package 'pkgname'
970 Configuration flags can be specified on the command line and these extend the project
971 configuration from the 'cabal.project', 'cabal.project.local' and other files.
973 .. option:: --repl-options=FLAG
975     To avoid ``ghci``-specific flags from triggering unneeded global rebuilds, these
976     flags are stripped from the internal configuration. As a result,
977     ``--ghc-options`` will no longer (reliably) work to pass flags to ``ghci`` (or
978     other REPLs). Instead, you should use the ``--repl-options`` flag to
979     specify these options to the invoked REPL.
981 .. option:: --repl-no-load
983     Disables the loading of target modules at startup.
985 .. option:: -b DEPENDENCIES or -bDEPENDENCIES, --build-depends=DEPENDENCIES
987     A way to experiment with libraries without needing to download
988     them manually or to install them globally.
990     This command opens a REPL with the current default target loaded, and a version
991     of the ``vector`` package matching that specification exposed.
993     ::
995         $ cabal repl --build-depends="vector >= 0.12 && < 0.13"
997     Both of these commands do the same thing as the above, but only expose ``base``,
998     ``vector``, and the ``vector`` package's transitive dependencies even if the user
999     is in a project context.
1001     ::
1003         $ cabal repl --ignore-project --build-depends="vector >= 0.12 && < 0.13"
1004         $ cabal repl --project='' --build-depends="vector >= 0.12 && < 0.13"
1006     This command would add ``vector``, but not (for example) ``primitive``, because
1007     it only includes the packages specified on the command line (and ``base``, which
1008     cannot be excluded for technical reasons).
1010     ::
1012         $ cabal repl --build-depends=vector --no-transitive-deps
1014 ``cabal repl`` can open scripts by passing the path to the script as the target.
1018     $ cabal repl path/to/script
1020 The configuration information for the script is cached under the cabal directory
1021 and can be pre-built with ``cabal build path/to/script``.
1022 See ``cabal run`` for more information on scripts.
1024 .. option:: --enable-multi-repl
1026     Allow starting GHCi with multiple targets.
1027     This requires GHC with multiple home unit support (GHC-9.4+)
1029     The closure of required components will be loaded.
1031 .. option:: --disable-multi-repl
1033     Disallow starting GHCi with multiple targets. This reverts back to the behaviour
1034     in version 3.10 and earlier where only a single component can be loaded at
1035     once.
1037 .. _cabal run:
1039 cabal run
1040 ^^^^^^^^^
1042 ``cabal run [TARGET] [FLAGS] [-- EXECUTABLE_FLAGS]`` runs the executable
1043 specified by the target, which can be a component, a package or can be left
1044 blank, as long as it can uniquely identify an executable within the project.
1045 Tests and benchmarks are also treated as executables.
1047 See `the build section <#cabal-build>`__ for the target syntax.
1049 When ``TARGET`` is one of the following:
1051 - A component target: execute the specified executable, benchmark or test suite.
1053 - A package target:
1054    1. If the package has exactly one executable component, it will be selected.
1055    2. If the package has multiple executable components, an error is raised.
1056    3. If the package has exactly one test or benchmark component, it will be selected.
1057    4. Otherwise an issue is raised.
1059 - The path to a script: execute the script at the path.
1061 - Empty target: Same as package target, implicitly using the package from the current
1062   working directory.
1064 Except in the case of the empty target, the strings after it will be
1065 passed to the executable as arguments.
1067 If one of the arguments starts with ``-`` it will be interpreted as
1068 a cabal flag, so if you need to pass flags to the executable you
1069 have to separate them with ``--``.
1073     $ cabal run target -- -a -bcd --argument
1075 ``run`` supports running script files that use a certain format.
1076 Scripts look like:
1080     #!/usr/bin/env cabal
1081     {- cabal:
1082     build-depends: base ^>= 4.14
1083                 , shelly ^>= 1.10
1084     -}
1085     {- project:
1086     with-compiler: ghc-8.10.7
1087     -}
1089     main :: IO ()
1090     main = do
1091         ...
1093 Where there cabal metadata block is mandatory and contains fields from a
1094 package executable block, and the project metadata block is optional and
1095 contains fields that would be in the cabal.project file in a regular project.
1097 Only some fields are supported in the metadata blocks, and these fields are
1098 currently not validated. See
1099 `#8024 <https://github.com/haskell/cabal/issues/8024>`__ for details.
1101 A script can either be executed directly using `cabal` as an interpreter or
1102 with the command:
1106     $ cabal run path/to/script
1108 The executable is cached under the cabal directory, and can be pre-built with
1109 ``cabal build path/to/script`` and the cache can be removed with
1110 ``cabal clean path/to/script``.
1112 A note on targets: Whenever a command takes a script target and it matches the
1113 name of another target, the other target is preferred. To load the script
1114 instead pass it as an explicit path: ./script
1116 By default, scripts are run at silent verbosity (``--verbose=0``). To show the
1117 build output for a script either use the command
1121     $ cabal run --verbose=n path/to/script
1123 or the interpreter line
1127     #!/usr/bin/env -S cabal run --verbose=n
1129 For more information see :cfg-field:`verbose`
1131 cabal bench
1132 ^^^^^^^^^^^
1134 ``cabal bench [TARGETS] [FLAGS]`` runs the specified benchmarks
1135 (all the benchmarks in the current package by default), first ensuring
1136 they are up to date.
1138 ``cabal bench`` inherits flags of the ``bench`` subcommand of ``Setup.hs``,
1139 :ref:`see the corresponding section <setup-bench>`.
1141 cabal test
1142 ^^^^^^^^^^
1144 ``cabal test [TARGETS] [FLAGS]`` runs the specified test suites
1145 (all the test suites in the current package by default), first ensuring
1146 they are up to date.
1148 ``cabal test`` inherits flags of the ``test`` subcommand of ``Setup.hs``
1149 (:ref:`see the corresponding section <setup-test>`) with one caveat: every
1150 ``Setup.hs test`` flag receives the ``test-`` prefix if it already does
1151 not have one; e.g. ``--show-details`` becomes ``--test-show-details`` but
1152 ``--test-wrapper`` remains the same.
1154 cabal exec
1155 ^^^^^^^^^^
1157 ``cabal exec [FLAGS] [--] COMMAND [--] [ARGS]`` runs the specified command
1158 using the project's environment. That is, passing the right flags to compiler
1159 invocations and bringing the project's executables into scope.
1161 .. _command-group-ship:
1163 Sanity checks and shipping
1164 --------------------------
1166 cabal check
1167 ^^^^^^^^^^^
1169 ``cabal check [FLAGS]`` checks the package for common mistakes (e.g.: if
1170 it is missing important fields like ``synopsis``, if it is using
1171 tricky GHC options, etc.).
1173 Run ``cabal check`` in the folder where your ``.cabal`` package file is.
1175 .. option:: -i, --ignore=WARNING
1177     Ignore a specific type of warning (e.g. ``--ignore=missing-upper-bounds``).
1178     Check the list of warnings for which constructor to use.
1180 .. option:: -v[n], --verbose[=n]
1182     Control verbosity (n is 0--3, default verbosity level is 1).
1184 Issues are classified as ``Warning``\s and ``Error``\s. The latter correspond
1185 to Hackage requirements for uploaded packages: if no error is reported,
1186 Hackage should accept your package. If errors are present ``cabal check``
1187 exits with ``1`` and Hackage will refuse the package.
1189 A list of all warnings with their constructor:
1191 - ``parser-warning``: inherited from parser.
1192 - ``no-name-field``: missing ``name`` field.
1193 - ``no-version-field``: missing ``version`` field.
1194 - ``no-target``: missing target in ``.cabal``.
1195 - ``unnamed-internal-library``: unnamed internal library.
1196 - ``duplicate-sections``: duplicate name in target.
1197 - ``illegal-library-name``: internal library with same name as package.
1198 - ``no-modules-exposed``: no module exposed in library.
1199 - ``signatures``: ``signatures`` used with ``cabal-version`` < 2.0.
1200 - ``autogen-not-exposed``: ``autogen-module`` neither in ``exposed-modules`` nor ``other-modules``.
1201 - ``autogen-not-included``: ``autogen-include`` neither in ``include`` nor ``install-includes``.
1202 - ``no-main-is``: missing ``main-is``.
1203 - ``unknown-extension-main``: ``main-is`` is not ``.hs`` nor ``.lhs``.
1204 - ``c-like-main``: C-like source file in ``main-is`` with ``cabal-version`` < 1.18.
1205 - ``autogen-other-modules``: ``autogen-module`` not in ``other-modules``.
1206 - ``autogen-exe``: ``autogen-include`` not in ``includes``.
1207 - ``unknown-testsuite-type``: unknown test-suite type.
1208 - ``unsupported-testsuite``: unsupported test-suite type.
1209 - ``unknown-bench``: unknown benchmark type.
1210 - ``unsupported-bench``: unsupported benchmark type.
1211 - ``bench-unknown-extension``: ``main-is`` for benchmark is neither ``.hs`` nor ``.lhs``.
1212 - ``invalid-name-win``: invalid package name on Windows.
1213 - ``reserved-z-prefix``: package with ``z-`` prexif (reseved for Cabal.
1214 - ``no-build-type``: missing ``build-type``.
1215 - ``undeclared-custom-setup``: ``custom-setup`` section without ``build-type: Custom``
1216 - ``unknown-compiler-tested``: unknown compiler in ``tested-with``.
1217 - ``unknown-languages``: unknown languages.
1218 - ``unknown-extension``: unknown extensions.
1219 - ``languages-as-extensions``: languages listed as extensions.
1220 - ``deprecated-extensions``: deprecated extensions.
1221 - ``no-category``: missing ``category`` field.
1222 - ``no-maintainer``: missing ``maintainer`` field.
1223 - ``no-synopsis``: missing ``synopsis`` field.
1224 - ``no-description``: missing ``description`` field.
1225 - ``no-syn-desc``: missing ``synopsis`` or ``description`` field.
1226 - ``long-synopsis``: ``synopsis`` longer than 80 characters.
1227 - ``short-description``: ``description`` shorter than ``synopsis``.
1228 - ``invalid-range-tested``: invalid ``tested-with`` version range.
1229 - ``impossible-dep``: impossible internal library version range dependency.
1230 - ``impossible-dep-exe``: impossible internal executable version range dependency.
1231 - ``no-internal-exe``: missing internal executable.
1232 - ``license-none``: ``NONE`` in ``license`` field.
1233 - ``no-license``: no ``license`` field.
1234 - ``all-rights-reserved``: “All rights reserved” license.
1235 - ``license-parse``: license not to be used with ``cabal-version`` < 1.4.
1236 - ``unknown-license``: unknown license.
1237 - ``bsd4-license``: uncommon BSD (BSD4) license.
1238 - ``unknown-license-version``: unknown license version.
1239 - ``no-license-file``: missing license file.
1240 - ``unrecognised-repo-type``: unrecognised kind of source-repository.
1241 - ``repo-no-type``: missing ``type`` in ``source-repository``.
1242 - ``repo-no-location``: missing ``location`` in ``source-repository``.
1243 - ``repo-no-module``: missing ``module`` in ``source-repository``.
1244 - ``repo-no-tag``: missing ``tag`` in ``source-repository``.
1245 - ``repo-relative-dir``: ``subdir`` in ``source-repository`` must be relative.
1246 - ``repo-malformed-subdir``: malformed ``subdir`` in ``source-repository``.
1247 - ``option-fasm``: unnecessary ``-fasm``.
1248 - ``option-fhpc``: unnecessary ``-fhpc``.
1249 - ``option-prof``: unnecessary ``-prof``.
1250 - ``option-o``: unnecessary ``-o``.
1251 - ``option-hide-package``: unnecessary ``-hide-package``.
1252 - ``option-make``: unnecessary ``--make``.
1253 - ``option-optimize``: unnecessary disable optimization flag.
1254 - ``option-o1``: unnecessary optimisation flag (``-O1``).
1255 - ``option-o2``: unnecessary optimisation flag (``-O2``).
1256 - ``option-split-section``: unnecessary ``-split-section``.
1257 - ``option-split-objs``: unnecessary ``-split-objs``.
1258 - ``option-optl-wl``:unnecessary ``-optl-Wl,-s``.
1259 - ``use-extension``: use ``extension`` field instead of ``-fglasgow-exts``.
1260 - ``option-rtsopts``: unnecessary ``-rtsopts``.
1261 - ``option-with-rtsopts``: unnecessary ``-with-rtsopts``.
1262 - ``option-opt-c``: unnecessary ``-O[n]`` in C code.
1263 - ``cpp-options``: unportable ``-cpp-options`` flag.
1264 - ``misplaced-c-opt``: C-like options in wrong cabal field.
1265 - ``relative-path-outside``: relative path outside of source tree.
1266 - ``absolute-path``: absolute path where not allowed.
1267 - ``malformed-relative-path``: malformed relative path.
1268 - ``unreliable-dist-path``: unreliable path pointing inside ``dist``.
1269 - ``glob-syntax-error``: glob syntax error.
1270 - ``recursive-glob``: recursive glob including source control folders.
1271 - ``invalid-path-win``: invalid path on Windows.
1272 - ``long-path``: path too long (POSIX, 255 ASCII chars).
1273 - ``long-name``: path *name* too long (POSIX, 100 ASCII chars).
1274 - ``name-not-portable``: path non portable (POSIX, split requirements).
1275 - ``empty-path``: empty path.
1276 - ``test-cabal-ver``: ``test-suite`` used with ``cabal-version`` < 1.10.
1277 - ``default-language``: ``default-language`` used with ``cabal-version`` < 1.10.
1278 - ``no-default-language``: missing ``default-language``.
1279 - ``extra-doc-files``: ``extra-doc-files`` used with ``cabal-version`` < 1.18.
1280 - ``multilib``: multiple ``library`` sections with ``cabal-version`` < 2.0.
1281 - ``reexported-modules``: ``reexported-modules`` with ``cabal-version`` < 1.22.
1282 - ``mixins``: ``mixins`` with ``cabal-version`` < 2.0.
1283 - ``extra-framework-dirs``: ``extra-framework-dirs`` with ``cabal-version`` < 1.24.
1284 - ``default-extensions``: ``default-extensions`` with ``cabal-version`` < 1.10.
1285 - ``extensions-field``: deprecated ``extensions`` field used with ``cabal-version`` ≥ 1.10
1286 - ``unsupported-sources``: ``asm-sources``, ``cmm-sources``, ``extra-bundled-libraries`` or ``extra-library-flavours`` used with ``cabal-version`` < 3.0.
1287 - ``extra-dynamic``: ``extra-dynamic-library-flavours`` used with cabal-version < 3.0.
1288 - ``virtual-modules``: ``virtual-modules`` used with cabal-version < 2.2.
1289 - ``source-repository``: ``source-repository`` used with ``cabal-version`` 1.6.
1290 - ``incompatible-extension``: incompatible language extension with ``cabal-version``.
1291 - ``no-setup-depends``: missing ``setup-depends`` field in ``custom-setup`` with ``cabal-version`` ≥ 1.24.
1292 - ``dependencies-setup``: missing dependencies in ``custom-setup`` with ``cabal-version`` ≥ 1.24.
1293 - ``no-autogen-paths``: missing autogen ``Paths_*`` modules in ``autogen-modules`` (``cabal-version`` ≥ 2.0).
1294 - ``no-autogen-pinfo``: missing autogen ``PackageInfo_*`` modules in ``autogen-modules`` *and* ``exposed-modules``/``other-modules`` (``cabal-version`` ≥ 2.0).
1295 - ``no-glob-match``: glob pattern not matching any file.
1296 - ``glob-no-extension``: glob pattern not matching any file becuase of lack of extension matching (`cabal-version` < 2.4).
1297 - ``glob-missing-dir``: glob pattern trying to match a missing directory.
1298 - ``unknown-os``: unknown operating system name in condition.
1299 - ``unknown-arch``: unknown architecture in condition.
1300 - ``unknown-compiler``: unknown compiler in condition.
1301 - ``missing-bounds-important``: missing upper bounds for important dependencies (``base``, and for ``custom-setup`` ``Cabal`` too).
1302 - ``missing-upper-bounds``: missing upper bound in dependency (excluding test-suites and benchmarks).
1303 - ``suspicious-flag``: troublesome flag name (e.g. starting with a dash).
1304 - ``unused-flag``: unused user flags.
1305 - ``non-ascii``: non-ASCII characters in custom field.
1306 - ``rebindable-clash-paths``: ``Rebindable Syntax`` with ``OverloadedStrings``/``OverloadedStrings`` plus autogenerated ``Paths_*`` modules with ``cabal-version`` < 2.2.
1307 - ``rebindable-clash-info``: ``Rebindable Syntax`` with ``OverloadedStrings``/``OverloadedStrings`` plus autogenerated ``PackageInfo_*`` modules with ``cabal-version`` < 2.2.
1308 - ``werror``: ``-WError`` not under a user flag.
1309 - ``unneeded-j``: suspicious ``-j[n]`` usage.
1310 - ``fdefer-type-errors``: suspicious ``-fdefer-type-errors``.
1311 - ``debug-flag``: suspicious ``-d*`` debug flag for distributed package.
1312 - ``fprof-flag``: suspicious ``-fprof-*`` flag.
1313 - ``missing-bounds-setup``: missing upper bounds in ``setup-depends``.
1314 - ``duplicate-modules``: duplicate modules in target.
1315 - ``maybe-duplicate-modules``: potential duplicate module in target (subject to conditionals).
1316 - ``bom``: unicode byte order mark (BOM) character at start of file.
1317 - ``name-no-match``: filename not matching ``name``.
1318 - ``no-cabal-file``: no ``.cabal`` file found in folder.
1319 - ``multiple-cabal-file``: multiple ``.cabal`` files found in folder.
1320 - ``unknown-file``: path refers to a file which does not exist.
1321 - ``missing-setup``: missing ``Setup.hs`` or ``Setup.lsh``.
1322 - ``missing-conf-script``: missing ``configure`` script with ``build-type: Configure``.
1323 - ``unknown-directory``: paths refer to a directory which does not exist.
1324 - ``no-repository``: missing ``source-repository`` section.
1325 - ``no-docs``: missing expected documentation files (changelog).
1326 - ``doc-place``: documentation files listed in ``extra-source-files`` instead of ``extra-doc-files``.
1329 cabal sdist
1330 ^^^^^^^^^^^
1332 ``cabal sdist [FLAGS] [PACKAGES]`` takes the crucial files needed to build ``PACKAGES``
1333 and puts them into an archive format ready for upload to Hackage. These archives are stable
1334 and two archives of the same format built from the same source will hash to the same value.
1336 ``cabal sdist`` takes the following flags:
1338 .. option:: -l, --list-only
1340     Rather than creating an archive, lists files that would be included.
1342     Output is to ``stdout`` by default. The file paths are relative to the project's root
1343     directory.
1345 .. option:: -o PATH or -oPATH, --output-directory=PATH
1347     Sets the output dir, if a non-default one is desired. The default is
1348     ``dist-newstyle/sdist/``. ``--output-directory -`` will send output to ``stdout``
1349     unless multiple archives are being created.
1351 .. option:: --null-sep
1353     Only used with ``--list-only``. Separates filenames with a NUL
1354     byte instead of newlines.
1356 ``sdist`` is inherently incompatible with sdist hooks (which were removed in `Cabal-3.0`),
1357 not due to implementation but due to fundamental core invariants
1358 (same source code should result in the same tarball, byte for byte)
1359 that must be satisfied for it to function correctly in the larger build ecosystem.
1360 ``autogen-modules`` is able to replace uses of the hooks to add generated modules, along with
1361 the custom publishing of Haddock documentation to Hackage.
1363 cabal upload
1364 ^^^^^^^^^^^^
1366 ``cabal upload [FLAGS] TARFILES`` uploads source packages or documentation
1367 to Hackage.
1369 .. option:: --publish
1371     Publish the package immediately instead of uploading it as a
1372     `package candidate <https://hackage.haskell.org/upload#candidates>`__
1373     (make sure everything is fine, you cannot delete published packages
1374     on Hackage!).
1376 .. option:: -d, --documentation
1378     Upload documentation instead of a source package. To upload
1379     documentation for a published package (and not a candidate), add
1380     ``--publish``.
1382 .. option:: -t TOKEN or -tTOKEN, --token=TOKEN
1384     Your Hackage authentication token. You can create and delete 
1385     authentication tokens on Hackage's `account management page 
1386     <https://hackage.haskell.org/users/account-management>`__.
1388 .. option:: -u USERNAME or -uUSERNAME, --username=USERNAME
1390     Your Hackage username.
1392 .. option:: -p PASSWORD or -pPASSWORD, --password=PASSWORD
1394     Your Hackage password.
1396 .. option:: -P COMMAND or -PCOMMAND, --password-command=COMMAND
1398     Command to get your Hackage password.  Arguments with whitespace
1399     must be quoted (double-quotes only).  For example:
1401     ::
1403         --password-command='sh -c "grep hackage ~/secrets | cut -d : -f 2"'
1405     Or in the config file:
1407     ::
1409         password-command: sh -c "grep hackage ~/secrets | cut -d : -f 2"
1412 cabal report
1413 ^^^^^^^^^^^^
1415 ``cabal report [FLAGS]`` uploads build reports to Hackage.
1417 .. option:: -t TOKEN or -tTOKEN, --token=TOKEN
1419     Your Hackage authentication token. You can create and delete 
1420     authentication tokens on Hackage's `account management page 
1421     <https://hackage.haskell.org/users/account-management>`__.
1423 .. option:: -u USERNAME or -uUSERNAME, --username=USERNAME
1425     Your Hackage username.
1427 .. option:: -p PASSWORD or -pPASSWORD, --password=PASSWORD
1429     Your Hackage password.
1431 .. include:: references.inc