6

The current documentation of cabal shows a sandbox subcommand.

The respective page on github no longer contains the section on sandboxes.

I'm using cabal version 3.2.0.0, but the sandbox subcommand is absent. What is the correct way to manage sandboxes with cabal?

Apparently there's an overhaul going on with the documentation, there's mention of a Nix-style/new-/v2 commands but it's unclear to a noob what's the canonical way of using sandboxes with cabal.

danidiaz
  • 26,936
  • 4
  • 45
  • 95
Bernhard Wagner
  • 1,681
  • 12
  • 15

1 Answers1

9

They're no longer needed. The nix-style store does everything sandboxes did, but better. Just use use cabal build (cabal v2-build for pre-3.0 cabal's) and other cabal commands with impunity in a bare, sandbox-free directory.

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • Thanks, @Daniel, but how do I get the equivalent of a sandbox, i.e. a self-contained Haskell environment akin to a python venv? – Bernhard Wagner May 21 '20 at 17:13
  • 1
    @BernhardWagner To answer that properly, we'd need to know why you want one. What need do you have that isn't handled by v2-style installs? – Carl May 21 '20 at 17:19
  • 2
    @BernhardWagner All packages are built in a self-contained Haskell environment. (Or: what observations do you make that causes you to believe you do not already have a self-contained environment?) – Daniel Wagner May 21 '20 at 17:27
  • 2
    @BernhardWagner cabal >= 3 can store multiple versions of each library in a shared central store (previously, conflicts could arise when you did that, so separate sandboxes were added as an stopgap measure). When you are developing a package and invoke `cabal build`, your build process sees a "view" of the store that fits the `build-depends` in your cabal file. You don't need sandboxes, and you don't need to "cabal install" your dependencies individually: everything is handled by the `cabal build`. You might need to run `cabal update` once in a while to refresh the list of available packages. – danidiaz May 21 '20 at 18:23
  • I understood that basically whenever I develop a haskell project within a directory, it's in a sandbox by default. Python's venv in addition refers to a specific python version. Is that supported with cabal as well? – Bernhard Wagner May 22 '20 at 17:43
  • In the meantime I've found another post on stackoverflow dealing with a similar issue: https://stackoverflow.com/questions/58272366/haskell-cabal-v2-and-sandbox – Bernhard Wagner May 22 '20 at 17:52
  • 1
    @BernhardWagner You can ask for a specific compiler per-command with `-w`, or use `cabal configure` (still with `-w`) to use a specific compiler by default for future commands that don't have a `-w` flag. – Daniel Wagner May 22 '20 at 18:32