Cabal not present after latest Haskell install - haskell

I am trying latest Haskell from here on Windows7. I downloaded ghc-8.8.1-x86_64-unknown-mingw32.tar.xz (377.3 MB) and untarred it in a folder and added bin folder path to environment.
Now I can run ghc but cabal or cabal-install are not there.
Although I:\ghc-8.8.1\lib\Cabal-3.0.0.0 is there in package but there is no cabal.exe or cabal-install.exe
How can I get an run cabal in this setup? Thanks for your help.

GHC is just the compiler and a set of core libraries and executables, of which cabal-the-program is not one. The Cabal you found is a library for package management. The cabal program is part of the cabal-install package, and it depends on the Cabal library. Without cabal-install installed, you cannot cabal install cabal-install. Instead, you have to manually download the cabal program from the website. You can build it from source or you can use one of the pre-built binaries.

Related

What is the difference between install, v1-install, v2-install and new-install?

The commands install, v1-install, v2-install and new-install are simply described to "Install packages" when running man cabal. Are they different from one another? Which is the preferred option?
For modern versions of cabal-install, install, new-install and v2-install are the same. v1-install and the other v1- commands are obsolete and should not be used anymore.
Notice that, when developing a cabal package, the install command is largely unnecessary. Running cabal build and cabal repl will automatically install the required dependencies (listed in the build-depends: section of the cabal file).
cabal install is still useful in cases like the following:
Installing an executable from a package. Like the warp executable from the package wai-app-static. In those cases, the options --overwrite-policy, --install-method and --installdir are useful.
Creating a local package environment in some folder, so that "bare" invocations of ghc and ghci see some desired set of libraries. Like this. In those cases, the options --lib and --package-env are useful.

What is the common workflow of using cabal for personal project?

Assume I want to creat my own local library called MyLib, my workflow is:
$ cabal init
# # edit the ".cabal" file, set the "exposed-modules" as "MyLib"
# # edit "MyLib.hs" located in "src"
$ cabal sandbox init
$ cabal install
So my question is
is my workflow an acceptable one, or could it be better?
now I have a compiled library in .cabal-sandbox/lib, how could I use it or import MyLib from my another haskell project? It seems that packages downloaded from hackage through cabal install are stored in ~/.cabal, while my own locally installed package is not there.
what is the difference between cabal build and cabal install, it seems that after running cabal build, I could already run my lib through cabal repl, so what extra jobs does cabal install do?
I've never used cabal sandbox so I can't speak much to it.
cabal build compiles your source code into your dist directory.
cabal install takes your compiled source code and sends it to your ~/.cabal directory, and registers it in your ~/.ghc directory. Now you can import it into other code just as you would any other library you've installed with cabal.
In my personal projects, I use cabal configure, cabal build, cabal repl, and cabal install. And configure is kind of optional.

cabal-install and ghc 7.10.1

I just upgraded to ghc 7.10.1 and whenever I try use cabal-install I run into the following error:
ghc: ghc no longer supports single-file style package databases (dist/package.conf.inplace) use 'ghc-pkg init' to create the database with the correct format.
How do I fix this?
If you are on Mac OS X and are using homebrew it may be that you installed Cabal through haskell-platform package, which is outdated with no direct upgrade path.
You should uninstall haskell-platform and reinstall Cabal using the cabal-install package.
It could well be you have a newer cabal on your path but can't find it because the old one shadows it. So looking for where cabal may help you resolve that. Barring that, you can download a newer cabal binary from the cabal homepage.

Installing svgcairo on windows

I have managed to install cairo, but when I run cabal install svgcairo I get the following error:
setup.exe: The pkg-config package librsvg-2.0 version >=2.16.0 is required but it could not be found.
I'm on windows 8 x64, with cabal version 1.16.02 and ghc 7.6.3.
You need to install librsvg in a location that ghc can find first. Check out http://librsvg.sourceforge.net/download/ for downloads, but you might have to build it from source yourself, which is beyond the scope of this answer. Then just make sure that wherever you've installed the library is on your path and that pkg-config can find it, and you should be good to go.

How do you install packages/libraries without Cabal or Cabal-Install?

I'm trying to set up Haskell from scratch, on Ubuntu 11.04, without using the outdated Debian repository or Haskell-Platform.
I've installed GHC-7.0.4 from source with no problem, and now need to install Cabal (which appears to already be included in GHC in /usr/local/lib/ghc-7.0.4/Cabal-1.10.2.0) and Cabal Install.
The latter specifies several dependencies (parsec and network), each of which has several dependencies of their own (mtl, text, etc).
What's the command to install these packages, that I downloaded from hackage in tar.gz form?
Unpack, then runhaskell doesn't work.
I see Setup.lhs, but it's not clear what that's for or how to use it.
Most of the Haskell documentation I've found assumes you've installed from a repo or Haskell-Package and doesn't really explain this well.
cabal-install has a shell script that does this. If you download it from hackage and install it, you can start bootstrap.sh to install cabal-install. You can then use it to install other packages.
There are two different packages: Cabal and cabal-install. Cabal is a library, and cabal-install is an executable named cabal.
To install a package, cabal-install is an optional convenience wrapper around Cabal, but Cabal is required.
According to http://hackage.haskell.org/trac/ghc/wiki/Commentary/Libraries , Cabal is a 'zero-boot' package, so when you build GHC, Cabal and its dependencies are built for you automatically.
You can use ghc-pkg executable to check which packages are already installed:
# ghc-pkg list
Check if Cabal is in the list after you build GHC. If yes, you can install more packages without cabal-install using this documentation:
http://haskell.org/haskellwiki/Cabal/How_to_install_a_Cabal_package
I suggest you to install cabal-install first, and then install everything else using cabal-install executable. A usual commandine for global installation is this:
# runhaskell Setup configure
# runhaskell Setup build
# sudo runhaskell Setup install
Unpack a package tarball and run the commands in the folder with Setup.hs or Setup.lhs files. Note that a per-user non-root installation is also supported - Use runhaskell Setup configure --user
When you install cabal executable and its dependencies this way, use cabal install {package-name} to install more packages.
Note that Haskell Platform exists mostly because of the pain of installing cabal-install by yourself.

Resources