Trying out "cabal sandbox init" and cabal not recognizing the command "sandbox" - haskell

I'm trying out the tutorial about making a simple website with scotty but I get an error when I try the command "cabal sandbox init":
cabal: unrecognised command: sandbox (try --help)
Does anyone know what is wrong?

Is your Cabal/cabal-install version new enough? Sandboxes were introduced in Cabal 1.18. You can check the version with command cabal --version.
You might be able to upgrade with these commands:
cabal update
cabal install Cabal cabal-install

Related

Can't install "System.Random" by cabal

I try to install "System.Random" by cabal through Powershell & Git Bash.
getting this result.
PS C:\Users\xxx> cabal install random
Resolving dependencies...
Up to date
Warning: You asked to install executables, but there are no executables in
target: random. Perhaps you want to use --lib to install libraries instead.
And then I try to input like this
cabal install --lib random
Resolving dependencies...
and
cabal install random --lib
both output Resolving dependencies... Up to date without warning.
but ghci Could not find module `System.Random'
input cabal install random still having the same result with warning.
It is a bad idea to install packages globally, so cabal install doesn't do that. The package is built and placed into the Cabal package database, but GHC won't find it unless you specifically tell Cabal to point GHC at it:
cabal repl -b random # -b is short for --build-depends
# Note that cabal install isn't really necessary: the above command would have installed random if it wasn't there already
I think your Cabal/GHC installation might be outdated, however. When you do cabal install --lib random, recent versions of Cabal should write out an "environment file" at %APPDATA%\ghc\arch-os-ghcversion\environments\default, which GHC should then automatically read (GHCi should say something like Loaded package environment from ...), and it should then find the installed package. If you are using the latest version of everything,
cabal install --lib random
ghci
should work.

Haskell - Cabal Install parsec errors

I've been trying to install the parsec library for haskell but I'm running in to a lot of errors. Im very new to haskell & cabal and i don't quite understand the output of the log file.
the output of the log file is here:
http://pastebin.com/6hPQN1W4
I tried installing the packages that the log file said that it could not find, but i keep getting errors when trying to install the packages.
I reinstalled cabal and also ran cabal update, but this did not resolve the issue
any help will be appreciated?
I suggest using stack tool with its stackage infrastructure. Please see http://haskellstack.org for more details.
You could try installing parsec in a sandbox.
$ mkdir asdf
$ cd asdf
$ cabal sandbox init
cabalWriting a default package environment file to
/Users/steshaw/Projects/asdf/cabal.sandbox.config
Creating a new sandbox at /Users/steshaw/Projects/asdf/.cabal-sandbox
$ cabal install parsec
Resolving dependencies...
Notice: installing into a sandbox located at
/Users/steshaw/Projects/steshaw/asdf/.cabal-sandbox
Configuring mtl-2.2.1...
Configuring text-1.2.2.1...
Building text-1.2.2.1...
Building mtl-2.2.1...
Installed mtl-2.2.1
Installed text-1.2.2.1
Configuring parsec-3.1.11...
Building parsec-3.1.11...
Installed parsec-3.1.11

Cabal configure can't find an installed package inside a cabal sandbox

I've made a cabal sandbox, installed a package to it, yet runhaskell Setup configure complains that the package dependency that I just installed is missing.
I verified the package name and version and that's okay.
Running cabal install --dependencies-only says "all the requested packages are already installed".
What's going on & how can I fix it?
If relevant I've encountered this with QuickCheck-2.7.5 on Windows 7 with cabal-install 1.20.0.3 using cabal 1.20.0.1 and ghc 7.6.3.
Configuring through runhaskell Setup configure outputs:
Configuring MyPackage-0.1.0.0...
Setup.hs: At least the following dependencies are missing:
QuickCheck ==2.7.5
Instead of running runhaskell Setup configure, you should do cabal configure. runhaskell doesn't know about sandboxes.

'cabal run' gives "unrecognised command: run"

I'm attempting to create simple Cabal executable package.
The Cabal user guide's "Running executables" section says:
You can have Cabal build and run your executables by using the run command.
cabal run EXECUTABLE [-- EXECUTABLE_FLAGS]
Yet when I enter that command:
$ cabal run HelloWorld
I get this error message:
cabal: unrecognised command: run (try --help)
cabal --help tells me that, indeed, there is no run command.
Am I missing something? How do I run my executable?
I'm totally new to Haskell and Cabal; please let me know what info would be helpful to include here.
I'm on Mac OS X 10.8.5.
cabal --version gives:
cabal-install version 0.14.0
using version 1.14.0 of the Cabal library
ghc --version gives:
The Glorious Glasgow Haskell Compilation System, version 7.4.2
Your version of cabal-install is too old. The newest version of cabal-install is 1.20. You can upgrade to this version by running cabal install cabal-install.

Haskell Cabal regenerate documentation for all installed packages

How can I generate and install documentation for all locally installed cabal packages? I turned on the documentation flag in ~/.cabal/config which means that all newly installed packages will have documentation also generated. But how to generate documentation for all already installed packages?
Is there a way to automatically cabal install --reinstall all already installed packages? And more importantly, is that a good idea?
If you have a recent-ish version of cabal-install (>= 0.10, I think), you can try doing
$ cabal install --reinstall --upgrade-dependencies world
Unfortunately, it didn't work in my case:
$ cabal install --dry-run --reinstall world
Resolving dependencies...
cabal: cannot configure Agda-2.2.10. It requires haskell-src-exts >=1.9.6 &&
<1.10
For the dependency on haskell-src-exts >=1.9.6 && <1.10 there are these
packages: haskell-src-exts-1.9.6. However none of them are available.
haskell-src-exts-1.9.6 was excluded because haskell-src-exts-1.11.1 was
selected instead
haskell-src-exts-1.9.6 was excluded because hlint-1.8.12 requires
haskell-src-exts ==1.11.*
If you bump into an error like this, you can try manually editing the ~/.cabal/world file.
Please note that cabal install --only-dep --reinstall does not work.
If you are using a sandbox, you can do
cabal sandbox delete
cabal sandbox init
cabal install -j --only-dep --enable-documentation
The -j option allows it to build in parallel.
You could try something like this in bash.
for pkg in `ghc-pkg list --simple`
do
cabal install $pkg --reinstall
done
But I really don't know, whether it's a good idea.

Resources