Do Cabal recognize packages installed by system package manager - haskell

I had lately linker problem during compilation of Haskell code and I wonder whether cabal can find packages installed by OS package manger e.g. I install package X which depends on Y but Y is already installed by package manger (not cabal). Will cabal install it own version of Y? Wouldn't that cause problem when linking?

Yes, Cabal queries GHC to get a list of installed packages, and it will recognize packages installed by your package manager.

Related

Cabal not present after latest Haskell install

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.

Let Cabal-Install show the install plan

If I install a package using cabal install pkg then cabal will install all packages that pkg depends on. If there is a conflict with already installed packages then cabal shows which packages have to be installed freshly, which ones are updated and which installed ones will be broken.
Is there a way to get this list unconditionally instead of running the install procedure?
cabal install <pkg> --dry-run will print the packages that will be installed without actually performing any of the installation. It will not show this information though if the package is installed or similar.

Cabal can't determine GHC version

I am currently trying to update Cabal (1.14.0, cabal-install at version 0.14.0) by doing
cabal install cabal-install
However, this gives me an ExitFailure1 with the error
setup: The program ghc version >=6.4 is required but the
version of /usr/bin/ghc could not be determined.
But I'm definitely running a version of GHC that is greater than that.
$ /usr/bin/ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.4.2
It might be important that I'm on OSX 10.8 and that I installed Haskell through the Haskell Platform download for Mac.
Does anyone have advice on how to fix or work around this issue? I haven't been able to find any documentation on this problem.
Since you're on a Mac, why not try installing the excellent Homebrew package manager? Add /usr/local/bin to your PATH, and then it's just brew install cabal-install.
You can even brew install ghc haskell-platform.
To upgrade the package list, use brew upgrade, then you can see what needs updating with brew outdated and update them with brew update.
Of course, you can name individual packages to update also, and specify versions of packages. Homebrew keeps the "recipes" (Ruby scripts) for package management in its own git repository (by default in /usr/local).
Then you can get on with what you really wanted to do in the first place...write some code! (or build, in your case)

Haskell cabal install: missing C library iw

I'm running Fedora 19 x64, and
I'm trying to install xmobar via cabal install. After installing a bunch of dependencies, I'm stuck at
cabal: Missing dependency on a foreign library:
* Missing C library: iw
I can't find anything about this iw library and I'm a bit lost at how to continue.
I've got all of the standard c libs installed, as far as I can tell.
sudo yum install glibc-common glibc glibc-devel glibc-headers glibc-utils glibc-devel glib2-devel gcc-c++ gcc
Loaded plugins: auto-update-debuginfo, langpacks, refresh-packagekit
Package glibc-common-2.17-18.fc19.x86_64 already installed and latest version
Package glibc-2.17-18.fc19.x86_64 already installed and latest version
Package glibc-devel-2.17-18.fc19.x86_64 already installed and latest version
Package glibc-headers-2.17-18.fc19.x86_64 already installed and latest version
Package glibc-utils-2.17-18.fc19.x86_64 already installed and latest version
Package glibc-devel-2.17-18.fc19.x86_64 already installed and latest version
Package glib2-devel-2.36.3-3.fc19.x86_64 already installed and latest version
Package gcc-c++-4.8.1-1.fc19.x86_64 already installed and latest version
Package gcc-4.8.1-1.fc19.x86_64 already installed and latest version
Nothing to do
Under Ubuntu the same workaround:
cabal: Missing dependency on a foreign library:
* Missing C library: iw
was resolved though I thought that it can be also two libraries for C language build tools:
liwc : Tools for manipulating C source code
iwyu : Analyze #includes in C and C++ source files
after these additions & libiw-dev library new xmobar was compiled.
Libraries are packaged differently by your OS. For fedora, if you're missing library A, you often will find packages named libA and libA-devel. Luckily, you don't need to guess - instead just ask yum what packages has some file of interest. Below, I asked about the shared object file libiw.so.
yum whatprovides *libiw.so*
...
1:wireless-tools-devel-29-9.1.fc19.x86_64 : Development headers for the
: wireless-tools package
Repo : fedora
Matched from:
Filename : /usr/lib64/libiw.so
1:wireless-tools-29-9.1.fc19.x86_64 : Wireless ethernet configuration tools
Repo : installed
Matched from:
Provides : libiw.so.29()(64bit)
Filename : /lib64/libiw.so.29
I'm surprised Fedora would install without these packages, but if that's the case then obtaining the packages is just a yum install command away.
For anyone trying to install xmobar through cabal on arch,
the missing package that includes iw is called wireless_tools.
You can install that with
pacman -S wireless_tools

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.

Resources