Skip to content

Commit

Permalink
Warn that scripts cannot be package executables
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Sep 6, 2024
1 parent 3a6f73e commit d28dd07
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions doc/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ the following file named ``myscript``:
main :: IO ()
main = haskellSay "Hello, Haskell!"
The necessary sections of a ``.cabal`` file are placed
directly into the script as a comment.
The necessary sections of a package description that would otherwise be in a
``.cabal`` file are placed directly into the script as a comment.

Use the familiar ``cabal run`` command to execute this script:

Expand All @@ -222,6 +222,36 @@ can be run directly after setting the execute permission (+x):
See more in the documentation for :ref:`cabal run`.

.. warning::

Single-file scripts cannot also be part of a package, as an executable or
listed as a module.

.. code-block:: console
$ cat script-exclusivity.cabal
cabal-version: 3.0
name: script-exclusitivity
version: 1
executable my-script-exe
build-depends:
base,
haskell-say
main-is: myscript.hs
$ ./myscript.hs
Error: [Cabal-7070]
The run command can only run an executable as a whole, not files or modules
within them, but the target 'myscript.hs' refers to the file myscript.hs in the
executable my-script-exe.
$ cabal run myscript.hs
Error: [Cabal-7070]
The run command can only run an executable as a whole, not files or modules
within them, but the target 'myscript.hs' refers to the file myscript.hs in the
executable my-script-exe.
What Next?
----------

Expand Down

0 comments on commit d28dd07

Please sign in to comment.