cabal install bnfc missing directory - haskell

I'm new to Haskell, trying to write a program for compiler construction class.
I installed the haskell-platform package on my ubuntu 13.10, and then (without messing around with anything after installing haskell platform) tried to run the following command:
$ sudo cabal install bnfc
which results with:
Resolving dependencies...
Configuring BNFC-2.6.0.3...
cabal: The following installed packages are broken because other packages they
depend on are missing. These broken packages must be rebuilt before they can
be used.
package process-1.1.0.2 is broken due to missing package
directory-1.2.0.1-508733a890139bbedb8aa76468431462
Failed to install BNFC-2.6.0.3
cabal: Error: some packages failed to install:
BNFC-2.6.0.3 failed during the configure step. The exception was:
ExitFailure 1
As I try installing package directory it says the package is already installed.
Can anyone help?

I also am using Ubuntu 13.10 with the haskell platform package, and bnfc installs for me.
There are a few things you can check....
Don't use sudo with cabal install (by default cabal installs packages in your own home directory, using sudo might be causing trouble by giving the wrong file ownerships, or perhaps trying to put files in /root, or even overwriting /usr stuff)
Rename ~/.cabal/ and ~/.ghc/, and rebuild them by running "cabal update" (You may need to re-add ~/.cabal/bin/cabal from the moved location after the move). These hold installed packages and their info.... Since you have a new vanilla install, these should basically be empty, although the meta info in them may be corrupt. (if for some reason this makes things worse, you can always restore the original directory.... If it solves the problem, you can delete the original .cabal and .ghc)
You can get more info about why a package isn't installing by doing the following
cabal unpack bnfc #This will download and unpack the source code
cd BNFC-2.6.0.3 #enter the newly created source directory
cabal configure #This checks that all system dependencies are met
cabal build #This builds the package
cabal install #This installs the package in ~/.cabal/
(You may have to iterate to another package if a dependency isn't met)
I think 2. may solve your problem, as the error message you showed implies that the build process is hooked on finding a very specific version of the directory package, rather than the latest one. This happened to me once and cleaning out .cabal solved the problem for me.

Related

How to manually install package to a project that uses cabal

I was hoping to use a library that is on Hackage. But it turns out that the maintainer of the package has abandoned the library for some time and now it's not compiling due to minor problems. Now that I fixed the problems, what is the best way to link it with my cabal project until my PR is merged into the upstream
To install it like "cabal install ..." would install it, try this:
Use "cabal get pkgname-X.Y.Z" to get the source from Hackage; it places the source in the directory pkgname-X.Y.Z
cd into the source directory and apply your patches
Run cabal install
There are other options if you are using stack or cabal sandboxes.

Cabal install reports package as installed, but Setup configure reports it as missing

I am using ghc-7.6.3 with cabal-install version 1.18.0.5 using version 1.18.1.3 of the Cabal library. My operating system is Debian Wheezy 7.5.
I have a fresh cabal install, and that I have removed the .ghc from my home directory.
After that I have changed the cabal config file and set:
remote-repo: stackage-nightly-2014-12-15:http://www.stackage.org/snapshot/nightly-2014-12-15
After that I did (following this documentation)
$ cabal update
$ cabal install alex happy yesod-bin
and the build complained that it cannot build package system-filepath-0.4.12.
So, I am trying to build package system-filepath-0.4.12 manually. After unpacking the archive, I cd-ed to the unpacked folder and entered:
$ ghc -o Setup Setup.hs
$ ./Setup configure
which gives:
Configuring system-filepath-0.4.12...
Setup: At least the following dependencies are missing:
text >=0.7.1
But
$ cabal install text
gives:
Resolving dependencies...
All the requested packages are already installed:
text-1.1.1.3
Use --reinstall if you want to reinstall anyway.
How is it possible that a package is reported as installed and missing at the same time?
Should I look for a more stable remote-repo configuration, is there something I can check that might fix the missing text package? Note that I am not using a sandbox.
EDIT
Thanks for pointing out that there are two package databases.
I have now tried both
$ cabal configure
$ cabal build
and
$ Setup configure --user
$ Setup build
Both give no error during configuration, but give the following error during the build phase:
Building system-filepath-0.4.12...
Preprocessing library system-filepath-0.4.12...
/usr/bin/ld: cannot find -lHStext-1.1.1.3-ghc7.8.3
collect2: error: ld returned 1 exit status
Try this instead
cd system-filepath--0.4.12
cabal configure
I am not sure why, but this works for me, whereas Setup.hs gave me the same error (truth be told, I always do it the cabal configure way, and am not sure if your way should also work).
There are (at least) two package databases: a global one available to all users, and a user-specific one. By default, Setup.hs looks in (and installs to) the global one, and cabal-install looks in (and installs to) the user-specific one. You can manually choose one or the other with --user and --global; so, you could fix this either by using
./Setup configure --user
or by
cabal install text --global
You can see the current state of the package databases with ghc-pkg, which will report information about both by default.

Failing to install Haskell uniplate library

I am trying to install Elm and the instructions are to install Haskell and then
sh> cabal update
sh> cabal install cabal-install
sh> cabal install -j Elm elm-repl elm-reactor elm-get
When I do, the cabal-install installation installs text-1.2.0.0 which conflicts with the text-1.1.0.0 which uniplate requires so uniplate and its dependents fail to install. Text-1.1.0.0 is installed and present but is rejected in favour of text-1.2.0.0, even though the target needs text-1.1.0.0.
Is there a way to insist that cabal use text-1.1.0.0?
Is there a way to get text-1.1.0.0 and text-1.2.0.0 to co-exist?
Is there a way to convince uniplate that it can accept text-1.2.0.0?
Or a way to make uniplate (or cabal) believe that version text-1.1.0.0 is actually installed? Would that even work?
When I explicitly try to install version 1.1.0.0 of text, I am told that a reinstall would break other packages. Apparently it is a downgrade and not a co-installation. cabal does not seem to have an option to allow to me install two versions of the same library at the same time.
If I uninstall Haskell and all the libraries and then re-install Elm (without installing cabal-install so I don't get text-1.2.0.0 installed so there is no clash), I get 100 or so lines of
package aeson-0.7.0.4-8f84b14cc682e4c9b009352420076a45 is unusable due to missing or recursive dependencies:
attoparsec-0.10.4.0-ec2d0a330db1f6e3a6a3b79471a403ef hashable-1.2.2.0-45bd22df8c4ead6b3a7fb1d08bb07f7d mtl-2.1.3.1-8bcc0591131896cfc8761a93703d4c61 scientific-0.2.0.2-5e275f5d96527da6dc1f05642692a484 syb-0.4.1-be94ebe67c3607f5df1dfcc1906f5d5c text-1.1.0.0-9bd69e9ace700e05fb08e463086bc383 unordered-containers-0.2.4.0-69836b34d13649bcfacc8fb0c9f53e64 vector-0.10.9.1-c550551354bc7c2b5a1d261f39b2f3f4
package aeson-pretty-0.7.1-5dc26d5a4560afe110e90283479a1251 is unusable due to missing or recursive dependencies:
aeson-0.7.0.4-8f84b14cc682e4c9b009352420076a45
text-1.1.0.0-9bd69e9ace700e05fb08e463086bc383
unordered-containers-0.2.4.0-69836b34d13649bcfacc8fb0c9f53e64
vector-0.10.9.1-c550551354bc7c2b5a1d261f39b2f3f4
package asn1-encoding-0.9.0-94e9066cccf7ead73bee5ae4aa982071 is unusable due to missing or recursive dependencies:
mtl-2.1.3.1-8bcc0591131896cfc8761a93703d4c61
package asn1-parse-0.9.0-af4efc4777a8a0d9d19a626d5e4b08ff is unusable due to missing or recursive dependencies:
asn1-encoding-0.9.0-94e9066cccf7ead73bee5ae4aa982071
mtl-2.1.3.1-8bcc0591131896cfc8761a93703d4c61
text-1.1.0.0-9bd69e9ace700e05fb08e463086bc383
I have no idea at all how in resolve this or where to even try. Has anybody trod this path before and do you have any advice or pointers?
Thank you.
Edit
Installing in a sandbox changes the outcome only by degrees: text-1.1.0.0 does not clash with text-1.1.0.0 but still can not be loaded (despite being installed) and still remains the unsatisfied dependency.
blaze-builder is first to fail with cannot satisfy -package-id text-1.1.0.0-9bd69e9ace700e05fb08e463086bc383 yet the same log earlier stated [_12] trying: text-1.1.0.0/installed-9bd... (dependency of Elm-0.13) without apparent error or complaint.
cabal list shows both text-1.1.0.0 and text-1.2.0.0 as installed.
Installing blaze-builder separately looks the same. Dependency resolution shows
[_56] trying: blaze-builder-0.3.3.4 (user goal)
[_57] next goal: text (dependency of blaze-builder-0.3.3.4)
[_57] trying: text-1.1.0.0/installed-9bd...
[_58] done
All looks good but later, same log has
<command line>: cannot satisfy -package-id text-1.1.0.0-9bd69e9ace700e05fb08e463086bc383
(use -v for more information)
The ghc command line already had the -v flag and trying to re-run the command line copied from the log, with more -vs, gives an error with "can't find a package database at
dist/dist-sandbox-ad0bcd57/package.conf.inplace".
No package.conf.inplace seems to exist.
Further edit
On the Elm install page is a link to a BuildFromSource.hs script that is also supposed to work installing Elm. In the time that it took for that script to run and fail to work, I managed to install leiningen, node, npm, grunt and Clojure. I am now further along the road to getting Clojurescript installed in about 20 minutes than I am in getting Elm installed in nearly a week.
Elm looked really interesting but it is playing way too hard to get.
Thanks again to everyone who tried to help.
* Edit *
I finally got it.
Every executable installed by the installer at http://elm-lang.org/Install.elm caused a segfault.
The "Build from source" option at the same page did not work because the dependencies either stepped all over each other or could not get themselves straight in the first place.
The ghc at http://new-www.haskell.org/downloads/osx needs a later version of Mac OS than I have. (A link to older versions would not have gone astray.)
The solution (and it is obvious in retrospect) was to port install haskell-platform and port install hs-cabal-install and cabal install Elm .... I did have to run one of those installers twice because it could not find hackage.haskell.org (How is that a 'user' error?) but my hello-world.elm now compiles.
Thank you all again.
It looks like some dependency issues with elements you already have installed. You will probably need to install it in a sandbox.
First, update to the latest version of cabal:
$ cabal update
$ cabal install cabal cabal-install
Next, make sure you have the installed version of cabal on your $PATH.
$ which cabal
> /path/to/cabal/bin/cabal
If it says something like /usr/bin/cabal you will need to export cabal to be on your $PATH. For me this is `/home/username/.cabal/bin
$ export PATH=/path/to/cabal/bin/cabal;$PATH
Run which cabal again and ensure it is pointing to that path.
Now that you have the latest version of cabal. Run the following:
$ mkdir elm
$ cd elm
$ cabal sandbox init
This will initialize a sandbox where dependencies are completely independent of your other installs. Within this directory, you should be able to install the elm platform by running:
$ cabal install Elm elm-repl elm-reactor elm-get
These will be installed in a sub-directory called .cabal-sanbox/bin/ For convenience, you will probably want to add this to your $PATH so you can run the executables from any directory.
Hope this helps!

can't build lambdabot with ghc-7.8 (# haskell-src-exts)

I was trying to install lambdabot with ghc-7.8.2, but encountered an error while installing haskell-src-exts. To diagnose the issue, I tried
cabal install haskell-src-exts -v3
and get the following errors. I am using Windows XP 64-bit. I don't know if this has anything to do with spaces in windows directory names. Any ideas/pointer how to fix the problem?
...
[_18] next goal: array (dependency of haskell-src-exts-1.15.0.1)
[_18] trying: array-0.5.0.0/installed-d6d...
[_19] done
Ready to install haskell-src-exts-1.15.0.1
Extracting C:\Documents and Settings\ting\Application
Waiting for install task to finish...
Data\cabal\packages\hackage.haskell.org\haskell-src-exts\1.15.0.1\haskell-src-exts-1.15.0.1.tar.gz
to C:\DOCUME~1\ting\LOCALS~1\Temp\haskell-src-exts-1.15.0.1-3008...
Renaming
'C:\DOCUME~1\ting\LOCALS~1\Temp\haskell-src-exts-1.15.0.1-3008\haskell-src-exts-1.15.0.1\dist'
to
'C:\DOCUME~1\ting\LOCALS~1\Temp\haskell-src-exts-1.15.0.1-3008\haskell-src-exts-1.15.0.1\dist-tmp'.
creating
C:\DOCUME~1\ting\LOCALS~1\Temp\haskell-src-exts-1.15.0.1-3008\haskell-src-exts-1.15.0.1\dist
Renaming
'C:\DOCUME~1\ting\LOCALS~1\Temp\haskell-src-exts-1.15.0.1-3008\haskell-src-exts-1.15.0.1\dist-tmp'
to
'C:\DOCUME~1\ting\LOCALS~1\Temp\haskell-src-exts-1.15.0.1-3008\haskell-src-exts-1.15.0.1\dist'.
Failed to install haskell-src-exts-1.15.0.1
Last 10 lines of the build log ( C:\Documents and Settings\ting\Application Data\cabal\logs\haskell-src-exts-1.15.0.1.log ):
cabal.exe: C:\Documents and Settings\ting\Application
Data\cabal\logs\haskell-src-exts-1.15.0.1.log: does not exist
I figured it out. I tried to locate the log file as the comments suggested. However, in the cabal/log folder, there are only two log files for hashtable and haskline after running cabal-install lambdabot on a fresh ghc-7.8 installation.
To see if this error has anything to do with the spaces in the default cabal directory, I used a folder without spaces and did manual installation:
$ cd /d/temp
$ cabal get haskell-src-exts
Unpacking to haskell-src-exts-1.15.0.1\
$ cd haskell-src-exts-1.15.0.1/ && cabal configure
Resolving dependencies...
[1 of 1] Compiling Main ( dist\setup\setup.hs, dist\setup\Main.o )
Linking .\dist\setup\setup.exe ...
Configuring haskell-src-exts-1.15.0.1...
setup.exe: The program 'happy' version >=1.17 is required but it could not be
found.
So, happy in the dependency is somehow missing and undetected by cabal. It turns out happy too has an issue using the default cabal install command, and it can be overcome by a manual installation in, e.g., /d/temp,
cabal get happy && cd happy* && cabal configure && cabal install
This installs happy and doing the same for haskell-src-exts installs the package correctly. But there are other errors along the way for installing lambdabot, none of which seems to like the one encountered here with haskell-src-exts and happy.

How to upgrade gtk2hsC2hs?

I am trying cabal install glib-0.12.3 under my Ubuntu 11.10 using cabal-install 0.10.2. However, it shows the following error messages:
setup: The program gtk2hsC2hs version >=0.13.5 is required but the version
found at /usr/bin/gtk2hsC2hs is version 0.13.4
cabal: Error: some packages failed to install:
glib-0.12.3 failed during the configure step. The exception was:
ExitFailure 1
After half an hour's search, I cannot find where this gtk2hsC2hs is. I dug into places like http://code.haskell.org/gtk2hs/tools/c2hs/, but could not seem to find the right version.
How could I upgrade my gtk2hsC2hs? Thanks!
It's part of the gtk2hs-buildtools package.
$ cabal install gtk2hs-buildtools
(maybe with the --global flag, depends on how you want to install packages in general) should provide you with the newest version that should be able to build the latest gtk2hs packages.
Since the old gtk2hsC2hs is in /usr/bin, make sure that the new one is either installed there (replacing the old) or in a directory appearing before /usr/bin in your $PATH. A default cabal install installs executables (on Linux) in $HOME/.cabal/bin, so it would be a good idea to have that the first directory in the $PATH.

Resources