Can't install haskell exceptions library through cabal because of missing files [duplicate] - haskell

I've recently reinstalled my Haskell environment as I thought I had hosed it beyond recovery after updating my Mac OS X to Mavericks.
Now every time I run cabal install cabal-install, I get the following error.
Resolving dependencies...
Configuring cabal-install-1.18.0.3...
/var/folders/4l/qbdvy5xj4q53skv0zn0lhw940000gp/T/8247.c:1:12:
warning: control reaches end of non-void function [-Wreturn-type]
int foo() {}
^
1 warning generated.
Building cabal-install-1.18.0.3...
Preprocessing executable 'cabal' for cabal-install-1.18.0.3...
Main.hs:118:8:
Could not find module `Distribution.Version'
There are files missing in the `Cabal-1.18.1.3' package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Failed to install cabal-install-1.18.0.3
cabal: Error: some packages failed to install:
cabal-install-1.18.0.3 failed during the building phase. The exception was:
ExitFailure 1
Abes-MacBook-Pro:artifact abe$ cabal install cabal-install
Resolving dependencies...
Configuring cabal-install-1.18.0.3...
/var/folders/4l/qbdvy5xj4q53skv0zn0lhw940000gp/T/8335.c:1:12:
warning: control reaches end of non-void function [-Wreturn-type]
int foo() {}
^
1 warning generated.
Building cabal-install-1.18.0.3...
Preprocessing executable 'cabal' for cabal-install-1.18.0.3...
Main.hs:118:8:
Could not find module `Distribution.Version'
There are files missing in the `Cabal-1.18.1.3' package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Failed to install cabal-install-1.18.0.3
cabal: Error: some packages failed to install:
cabal-install-1.18.0.3 failed during the building phase. The exception was:
ExitFailure 1
After googling around, I've found this: http://www.haskell.org/platform/ghc-clang-wrapper
Which I ran to wrap clang for Haskell, however the above error still occurs.
running ghc-pkg check
There are problems in package Cabal-1.18.1.3:
Warning: library-dirs: /Users/abe/Library/Haskell/ghc-7.6.3/lib/Cabal-1.18.1.3/lib doesn't exist or isn't a directory
Warning: haddock-interfaces: /Users/abe/Library/Haskell/ghc-7.6.3/lib/Cabal-1.18.1.3/doc/html/Cabal.haddock doesn't exist or isn't a file
Warning: haddock-html: /Users/abe/Library/Haskell/ghc-7.6.3/lib/Cabal-1.18.1.3/doc/html doesn't exist or isn't a directory
import-dirs: /Users/abe/Library/Haskell/ghc-7.6.3/lib/Cabal-1.18.1.3/lib doesn't exist or isn't a directory
file Distribution/Compat/Environment.hi is missing
file Distribution/Compat/Exception.hi is missing
file Distribution/Compat/ReadP.hi is missing
file Distribution/Compiler.hi is missing
file Distribution/InstalledPackageInfo.hi is missing
file Distribution/License.hi is missing
file Distribution/Make.hi is missing
file Distribution/ModuleName.hi is missing
file Distribution/Package.hi is missing
file Distribution/PackageDescription.hi is missing
file Distribution/PackageDescription/Check.hi is missing
file Distribution/PackageDescription/Configuration.hi is missing
file Distribution/PackageDescription/Parse.hi is missing
file Distribution/PackageDescription/PrettyPrint.hi is missing
file Distribution/PackageDescription/Utils.hi is missing
file Distribution/ParseUtils.hi is missing
file Distribution/ReadE.hi is missing
file Distribution/Simple.hi is missing
file Distribution/Simple/Bench.hi is missing
file Distribution/Simple/Build.hi is missing
file Distribution/Simple/Build/Macros.hi is missing
file Distribution/Simple/Build/PathsModule.hi is missing
file Distribution/Simple/BuildPaths.hi is missing
file Distribution/Simple/BuildTarget.hi is missing
file Distribution/Simple/CCompiler.hi is missing
file Distribution/Simple/Command.hi is missing
file Distribution/Simple/Compiler.hi is missing
file Distribution/Simple/Configure.hi is missing
file Distribution/Simple/GHC.hi is missing
file Distribution/Simple/Haddock.hi is missing
file Distribution/Simple/Hpc.hi is missing
file Distribution/Simple/Hugs.hi is missing
file Distribution/Simple/Install.hi is missing
file Distribution/Simple/InstallDirs.hi is missing
file Distribution/Simple/JHC.hi is missing
file Distribution/Simple/LHC.hi is missing
file Distribution/Simple/LocalBuildInfo.hi is missing
file Distribution/Simple/NHC.hi is missing
file Distribution/Simple/PackageIndex.hi is missing
file Distribution/Simple/PreProcess.hi is missing
file Distribution/Simple/PreProcess/Unlit.hi is missing
file Distribution/Simple/Program.hi is missing
file Distribution/Simple/Program/Ar.hi is missing
file Distribution/Simple/Program/Builtin.hi is missing
file Distribution/Simple/Program/Db.hi is missing
file Distribution/Simple/Program/Find.hi is missing
file Distribution/Simple/Program/GHC.hi is missing
file Distribution/Simple/Program/HcPkg.hi is missing
file Distribution/Simple/Program/Hpc.hi is missing
file Distribution/Simple/Program/Ld.hi is missing
file Distribution/Simple/Program/Run.hi is missing
file Distribution/Simple/Program/Script.hi is missing
file Distribution/Simple/Program/Types.hi is missing
file Distribution/Simple/Register.hi is missing
file Distribution/Simple/Setup.hi is missing
file Distribution/Simple/SrcDist.hi is missing
file Distribution/Simple/Test.hi is missing
file Distribution/Simple/UHC.hi is missing
file Distribution/Simple/UserHooks.hi is missing
file Distribution/Simple/Utils.hi is missing
file Distribution/System.hi is missing
file Distribution/TestSuite.hi is missing
file Distribution/Text.hi is missing
file Distribution/Verbosity.hi is missing
file Distribution/Version.hi is missing
file Language/Haskell/Extension.hi is missing
file Distribution/Compat/CopyFile.hi is missing
file Distribution/Compat/TempFile.hi is missing
file Distribution/GetOpt.hi is missing
file Distribution/Simple/GHC/IPI641.hi is missing
file Distribution/Simple/GHC/IPI642.hi is missing
file Paths_Cabal.hi is missing
cannot find libHSCabal-1.18.1.3.a on library path
Warning: haddock-interfaces: /Library/Haskell/ghc-7.6.3/lib/haskell-platform-2013.2.0.0/doc/html/haskell-platform.haddock doesn't exist or isn't a file
Warning: haddock-html: /Library/Haskell/ghc-7.6.3/lib/haskell-platform-2013.2.0.0/doc/html doesn't exist or isn't a directory
The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
Cabal-1.18.1.3
Why is my Haskell environment so phenomenally broken? And how can I fix it?

One approach is to remove your local ghc package cache:
$ cd ~/.ghc/ && rm -rf */package.conf.d
$ ghc-pkg --user recache
After you do this, try the cabal command again.
$ cabal install package-name
That should work. If it doesn't, try removing your cabal packages, then repeating the above steps:
$ rm -rf ~/.cabal
If you're still having trouble, the missing package may be referred to by the system ghc package cache. Run this command:
$ ghc-pkg --user recache
$ sudo ghc-pkg recache
$ ghc-pkg -v check
The last command should print the system cache. On my GNU/Linux sytem, it prints this:
using cache: /home/sudoman/.ghc/x86_64-linux-7.6.3/package.conf.d/package.cache
using cache: /var/lib/ghc/package.conf.d/package.cache
At that point, I don't have a solution for you based on experience, but you may want to consider removing the ghc system package cache like above, then doing a recache; or re-installing ghc/haskell-platform.

the problem stems from the fact that cabal can track multiple versions of the same package.
Running:
cabal install --reinstall Cabal-1.18.1.3
fixes the problem

Related

cabal build error `gcc` failed: connot find `#include`

I try to build qhull from hackage and get the error
fatal error: qhull_ra.h: No such file or directory
2 | #include "qhull_ra.h"
`gcc' failed in phase `C Compiler'. (Exit code: 1)
The file is in the Cdir and the relevant parts of the cabal file are
include-dirs: ./Cdir
C-sources: ./Cdir/libqhull_r.c
, ./Cdir/geom_r.c
, ...
The file qhull_ra.h is not listed as C-sources, because it is a header file.
I did not write the code and are not experienced with including C code into haskell packages. The failure occurs sometimes and sometimes not, but I cannot tell when. What is wrong? I want to upload the package (authorized by the author); what do I have to change to make it compile with cabal install?
I've noticed that cabal install is (since recently) much more strict than cabal build when looking for files. So, I believe here the problem is that your include files are not being picked up by cabal.
I think you can fix that by listing your header files in a includes: field. So at least:
include-dirs: Cdir
includes: qhull_ra.h
c-sources: Cdir/libqhull_r.c
, ...

Cabal on windows (from chocolatey) doesn't build projects with libraries

I am having issues building a project with a library using cabal installed with haskell-dev using chocolatey on windows (i.e. the recommended approach, everyting out of the box). I initially thought the issue was related to my specific project but it's actually easily reproduced by just creating a template project with
cabal init --libandexe
cabal configure
And then cabal build fails to build with the following errors:
cabal.exe: Failed to build testcabal1-0.1.0.0 (which is required by
exe:testcabal1 from testcabal1-0.1.0.0). The failure occurred during the final
install step. The exception was:
dieVerbatim: user error (cabal.exe:
'C:\ProgramData\chocolatey\lib\ghc\tools\ghc-8.10.2\bin\ghc-pkg.exe' exited
with an error:
testcabal1-0.1.0.0: Warning: library-dirs: C:\Program doesn't exist or isn't a
directory
testcabal1-0.1.0.0: Warning: dynamic-library-dirs: C:\Program doesn't exist or
isn't a directory
testcabal1-0.1.0.0: Warning: haddock-interfaces:
C:\projects\haskell\testcabal1\dist-newstyle\build\x86_64-windows\ghc-8.10.2\testcabal1-0.1.0.0\doc\html\testcabal1\testcabal1.haddock
doesn't exist or isn't a file
testcabal1-0.1.0.0: Warning: haddock-html:
C:\projects\haskell\testcabal1\dist-newstyle\build\x86_64-windows\ghc-8.10.2\testcabal1-0.1.0.0\doc\html\testcabal1
doesn't exist or isn't a directory
testcabal1-0.1.0.0: library-dirs: Files\Haskell is a relative path which makes
no sense (as there is nothing for it to be relative to). You can make paths
relative to the package database itself by using ${pkgroot}. (use --force to
override)
testcabal1-0.1.0.0: library-dirs: Platform\8.6.5\mingw\lib is a relative path
which makes no sense (as there is nothing for it to be relative to). You can
make paths relative to the package database itself by using ${pkgroot}. (use
--force to override)
testcabal1-0.1.0.0: dynamic-library-dirs: Files\Haskell is a relative path
which makes no sense (as there is nothing for it to be relative to). You can
make paths relative to the package database itself by using ${pkgroot}. (use
--force to override)
testcabal1-0.1.0.0: dynamic-library-dirs: Platform\8.6.5\mingw\lib is a
relative path which makes no sense (as there is nothing for it to be relative
to). You can make paths relative to the package database itself by using
${pkgroot}. (use --force to override)
)
It seems to have something to do with spaces in some directory names where cabal / ghc were installed by chocolatey? Any ideas?

How to convert perl modules into deb packages?

My team is delivering a product that requires some perl modules, and since we deliver a full OS installer (Ubuntu 12.04) we want those modules as .deb packages. I've been able to build some other perl (like Algorithm::LUHN, Env::C, Linux::PID and Config::Properties) by following the instructions here, but having problems with Apache2::SizeLimit
Tried with Apache-SizeLimit-0.96 and Apache-SizeLimit-0.97... and all the methods described in the doc. Also tried in different OSs versions; Ubuntu 14.04.2, Ubuntu 12.04.5 (clean install), all the attempts ended with the same error:
test#test:~$ dh-make-perl --build --cpan Apache::SizeLimit
Going to read '/home/test/.cpan/Metadata'
Database was generated on Thu, 19 Mar 2015 02:17:02 GMT
CPAN: Digest::SHA loaded ok (v5.61)
Checksum for /home/test/.cpan/sources/authors/id/P/PH/PHRED/Apache-SizeLimit-0.97.tar.gz ok
Apache-SizeLimit-0.97/
Apache-SizeLimit-0.97/Changes
Apache-SizeLimit-0.97/INSTALL
Apache-SizeLimit-0.97/lib/
Apache-SizeLimit-0.97/LICENSE
Apache-SizeLimit-0.97/Makefile.PL
Apache-SizeLimit-0.97/MANIFEST
Apache-SizeLimit-0.97/MANIFEST.SKIP
Apache-SizeLimit-0.97/META.json
Apache-SizeLimit-0.97/META.yml
Apache-SizeLimit-0.97/README
Apache-SizeLimit-0.97/t/
Apache-SizeLimit-0.97/t/apache/
Apache-SizeLimit-0.97/t/apache2/
Apache-SizeLimit-0.97/t/pod.t
Apache-SizeLimit-0.97/t/response/
Apache-SizeLimit-0.97/t/response/TestApache/
Apache-SizeLimit-0.97/t/response/TestApache2/
Apache-SizeLimit-0.97/t/response/TestApache2/basic.pm
Apache-SizeLimit-0.97/t/response/TestApache2/check_n_requests2.pm
Apache-SizeLimit-0.97/t/response/TestApache2/deprecated.pm
Apache-SizeLimit-0.97/t/response/TestApache2/zzz_check_n_requests.pm
Apache-SizeLimit-0.97/t/response/TestApache/basic.pm
Apache-SizeLimit-0.97/t/response/TestApache/check_n_requests2.pm
Apache-SizeLimit-0.97/t/response/TestApache/deprecated.pm
Apache-SizeLimit-0.97/t/response/TestApache/zzz_check_n_requests.pm
Apache-SizeLimit-0.97/t/apache2/all.t
Apache-SizeLimit-0.97/t/apache/all.t
Apache-SizeLimit-0.97/lib/Apache/
Apache-SizeLimit-0.97/lib/Apache2/
Apache-SizeLimit-0.97/lib/Apache2/SizeLimit.pm
Apache-SizeLimit-0.97/lib/Apache/SizeLimit/
Apache-SizeLimit-0.97/lib/Apache/SizeLimit.pm
Apache-SizeLimit-0.97/lib/Apache/SizeLimit/Core.pm
CPAN: File::Temp loaded ok (v0.22)
======================================================================
Unpacked tarball already existed, directory renamed to /home/test/Apache-SizeLimit-0.97.13910
======================================================================
Using META.json
Found: Apache2-SizeLimit 0.97 (libapache2-sizelimit-perl arch=all)
cat: /etc/mailname: No such file or directory
No APT contents can be loaded.
Please install 'apt-file' package (at least version 2.5.0) and
run 'apt-file update' as root.
Dependencies not updated.
Using maintainer: test
Found docs: README
cat: /etc/mailname: No such file or directory
Using rules: /usr/share/dh-make-perl/rules.dh7.tiny
cat: /etc/mailname: No such file or directory
make: Entering directory `/home/test/Apache-SizeLimit-0.97'
dh clean
dh_testdir
dh_auto_clean
dh_clean
make: Leaving directory `/home/test/Apache-SizeLimit-0.97'
make: Entering directory `/home/test/Apache-SizeLimit-0.97'
dh build
dh_testdir
dh_auto_configure
Can't find mod_perl installed
The error was: Can't locate mod_perl2.pm in #INC (#INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at Makefile.PL line 147.
dh_auto_configure: perl Makefile.PL INSTALLDIRS=vendor returned exit code 2
make: *** [build] Error 2
make: Leaving directory `/home/test/Apache-SizeLimit-0.97'
Cannot create deb package: 'debian/rules build' failed.
Will appreciate any help on fixing it
Sharing how it was solved. As #grant-mclean answered; I was missing a -dev package: the "apache2-dev" (apache2-threaded-dev).
With it, and skipping tests I was able to build the .deb package.
sudo apt-get install devscripts dh-make-perl libapache2-mod-perl2 libapache2-mod-perl2-dev apache2-threaded-dev
export DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS nocheck"
dh-make-perl --build --cpan Apache::SizeLimit
Usually when you're trying to build something on Debian and get a message about something being missing, you need to install a 'dev' package - one that contains things like header files that aren't needed by the runtime.
I'm just guessing, but in your case perhaps you need to install: libapache2-mod-perl2-dev

How to change library-dirs in ghc-pkg

I'm trying to compile haskell ghc from source. I try to configure my cabal config from different folder than /usr/. From the start it always succeed in building any package.
At some point (after installing package cabal-install), I change my config for cabal to include another "library-dirs". Then, something wrong happens (probably because wrong string to be inserted in field "library-dirs" in cabal config). So, I try to reconfigure my cabal config file again (I even delete the config file and try to clean the ghc package cache) and comment field "library-dirs" options but it still fails. I also already tried to remove the cabal package directory (a directory where cabal save the cache about the packages).
This is the output when using "ghc-pkg check" :
Warning: library-dirs: {stripped} doesn't exist or isn't a directory
This is the output right now when I building package using cabal or manually from Setup.hs :
sudo -E cabal --config-file=/opt/haskell/config/config install hashable -O2 --global --flags="-fllvm" --prefix=/opt/haskell 2>error --upgrade-dependencies --reinstall
Resolving dependencies...
Configuring hashable-1.2.1.0...
Building hashable-1.2.1.0...
Failed to install hashable-1.2.1.0
Last 10 lines of the build log ( /{stripped}/hashable-1.2.1.0.log ):
Data/Hashable/Class.hs:100:15: Warning:
Literal 15868100553162883236 is out of the Int range -9223372036854775808..9223372036854775807
[2 of 3] Compiling Data.Hashable.Generic ( Data/Hashable/Generic.hs, dist/build/Data/Hashable/Generic.o )
Data/Hashable/Generic.hs:20:1: Warning:
The import of ‛Bits’ from module ‛Data.Bits’ is redundant
[3 of 3] Compiling Data.Hashable ( Data/Hashable.hs, dist/build/Data/Hashable.o )
/usr/bin/ld: cannot find {stripped}: No such file or directory
collect2: error: ld returned 1 exit status
This is the cabal config file : (any default values are stripped)
remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
remote-repo-cache: /opt/haskell/cabal
world-file: /opt/haskell/cabal/world
extra-prog-path: /opt/haskell/cabal/bin
build-summary: /opt/haskell/cabal/logs/build.log
remote-build-reporting: anonymous
jobs: $ncpus
install-dirs global
prefix: /opt/haskell/
Can anybody help me or guide me ? Or at least tell me where ghc are actually save the information of "library-dirs" configuration for an uninstalled package ?
cabal -V
cabal-install version 1.18.0.2
using version 1.18.1.3 of the Cabal library
ghc -v
The Glorious Glasgow Haskell Compilation System, version 7.9.20140206
Thank you.
I believe this might be due to the fact that each package contains the full path to the location when it was first created. Look into. .ghc/YOUR_PLATFORM/package.conf.d(for me, it's .ghc/x86_64-darwin-7.6.3/package.conf.d). You'll see a lot of .conf files, and each will contain hardcoded paths:
[...]
import-dirs: /Users/pejvan/Library/Haskell/ghc-7.6.3/lib/pandoc-types-1.12.3.3/lib
library-dirs: /Users/pejvan/Library/Haskell/ghc-7.6.3/lib/pandoc-types-1.12.3.3/lib
[...]
haddock-interfaces: /Users/pejvan/Library/Haskell/ghc-7.6.3/lib/pandoc-types-1.12.3.3/doc/html/pandoc-types.haddock
haddock-html: /Users/pejvan/Library/Haskell/ghc-7.6.3/lib/pandoc-types-1.12.3.3/doc/html
You can either manually update the files for the contents to point to the right location or write a script which would do it for you.
Then you need to update the package.cache files (might require a sudo here and there):
pejvan$ ghc-pkg recache
pejvan$ ghc-pkg recache --user
Finally, check that everything is now fine:
pejvan$ ghc-pkg check

Trying to install Image.Codec.DevIL under windows. Needs pthread and IL. Can't get IL to work

This is the output from cabal install codec-image-devil:
Resolving dependencies...
Configuring Codec-Image-DevIL-0.2.3...
cabal: Missing dependency on a foreign library:
* Missing C library: IL
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
cabal: Error: some packages failed to install:
Codec-Image-DevIL-0.2.3 failed during the configure step. The exception was:
ExitFailure 1
I tried --extra-include-dirs and --extra-lib-dirs. but they didn't work. so I edited the .cabal in Codec-Image-DevIL-0.2.3.tar.gz. I don't know if I'm even supposed to change that. but it worked for pthread.
I added these two lines:
include-dirs: C:\Users\Rumbold\Documents\libs\IL\include, C:\Users\Rumbold\Documents\libs\pthread\include, .
extra-lib-dirs: C:\Users\Rumbold\Documents\libs\IL\lib, C:\Users\Rumbold\Documents\libs\pthread\lib, .
They are indented so they are in the Library section. I don't know if I got the format for lists right, just something i stumbled upon while googling. The libs and `header files are all in the correct place, I think.
any clue how i can get it to work?
Edit_1:
I got it to work with --extra-include-dirs and --extra-lib-dirs, so I don't need to edit the cabal anymore. but IL still doesn't work. is there a way to find out which files it's looking for?
Wdit_2:
Alright it works. I had to rename DevIL.lib and DevIL.dll to libIL.lib and libIL.dll. (not sure if I had to do both, but that's what I did. also kept them under their old names)
Edit_3:
Getting lots of errors like:
"cabal\Codec-Image-DevIL-0.2.3\ghc-6.12.3/libHSCodec-Image-DevIL-0.2.3.a(DevIL.o):fake:(.text+0x2379):
undefined reference to `ilGetInteger#4'"

Resources