I've had nothing but trouble using cabal, not sure if it's due to a lack of understanding, or a faulty mental model, but things have been tough.
At the moment I'm just trying to get ghc-mod to work for my vim plugins. It usually works for a day or two and then starts failing for seemingly no reason with an error, the error I receive seems to change from time to time, right now I'm getting this one:
$ ghc-mod check Main.hs
ghc-mod: /Users/chris/.stack/snapshots/x86_64-osx/lts-6.15/7.10.3/pkgdb/package.cache:
GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!)
Any ideas about how to fix this sort of thing? I've tried installing it again, but I get this (I think my cabal packages are all screwed up but don't know how to fix it):
$ cabal install ghc-mod
Resolving dependencies...
Downloading haskell-src-exts-1.17.1...
Configuring haskell-src-exts-1.17.1...
Failed to install haskell-src-exts-1.17.1
Build log ( /Users/chris/.cabal/logs/haskell-src-exts-1.17.1.log ):
cabal: Entering directory '/var/folders/6l/rdh2g5wn41s8vxchngkt02_c0000gn/T/cabal-tmp-45583/haskell-src-exts-1.17.1'
Configuring haskell-src-exts-1.17.1...
cabal: The program 'happy' version >=1.19 is required but it could not be
found.
cabal: Leaving directory '/var/folders/6l/rdh2g5wn41s8vxchngkt02_c0000gn/T/cabal-tmp-45583/haskell-src-exts-1.17.1'
cabal: Error: some packages failed to install:
ghc-mod-5.6.0.0 depends on haskell-src-exts-1.17.1 which failed to install.
haskell-src-exts-1.17.1 failed during the configure step. The exception was:
ExitFailure 1
hlint-1.9.35 depends on haskell-src-exts-1.17.1 which failed to install.
Edit:
Looked away for a second and tried again, now I'm getting this error, getting kinda sick of cabal changing its mind all the time:
$ ghc-mod check Main.hs
[1 of 5] Compiling CabalHelper.Common ( CabalHelper/Common.hs, /Users/chris/.ghc-mod/cabal-helper/CabalHelper/Common.o )
[2 of 5] Compiling CabalHelper.Licenses ( CabalHelper/Licenses.hs, /Users/chris/.ghc-mod/cabal-helper/CabalHelper/Licenses.o )
CabalHelper/Licenses.hs:53:18: error:
Ambiguous occurrence ‘lookupInstalledPackageId’
It could refer to either ‘Distribution.Simple.PackageIndex.lookupInstalledPackageId’,
imported from ‘Distribution.Simple.PackageIndex’ at CabalHelper/Licenses.hs:24:1-39
or ‘CabalHelper.Licenses.lookupInstalledPackageId’,
defined at CabalHelper/Licenses.hs:38:1
CabalHelper/Licenses.hs:74:10: error:
Ambiguous occurrence ‘lookupInstalledPackageId’
It could refer to either ‘Distribution.Simple.PackageIndex.lookupInstalledPackageId’,
imported from ‘Distribution.Simple.PackageIndex’ at CabalHelper/Licenses.hs:24:1-39
or ‘CabalHelper.Licenses.lookupInstalledPackageId’,
defined at CabalHelper/Licenses.hs:38:1
ghc-mod: readCreateProcess: /Users/chris/.stack/snapshots/x86_64-osx/lts-6.15/7.10.3/libexec/cabal-helper-wrapper "--with-ghc=/usr/local/bin/ghc" "--with-ghc-pkg=/usr/local/bin/ghc-pkg" "--with-cabal=cabal" "/Users/chris/dev/formatter" "/Users/chris/dev/formatter/.stack-work/dist/x86_64-osx/Cabal-1.24.0.0" "package-db-stack" "entrypoints" "source-dirs" "ghc-options" "ghc-src-options" "ghc-pkg-options" "ghc-merged-pkg-options" "ghc-lang-options" "licenses" "flags" "config-flags" "non-default-config-flags" "compiler-version" (exit 1): failed
This error was caused by having a mismatch between my local stack ghc version and the global ghc-mod ghc version, I updated the ghc version in the stack project to latest and everything is working fine.
Related
I saw a possible solution for an utf8 problem here: Read file with UTF-8 in Haskell as IO String. I wanted to try that out, but I'm having a problem I can't resolve.
When I run the command cabal v2-install encoding --lib almost everything works but fails in the end with these lines:
[8 of 8] Compiling Main ( /tmp/cabal-install.-169090/dist-newstyle/tmp/src-169090/encoding-0.8.5/dist/setup/setup.hs, /tmp/cabal-install.-169090/dist-newstyle/tmp/src-169090/encoding-0.8.5/dist/setup/Main.o )
Linking /tmp/cabal-install.-169090/dist-newstyle/tmp/src-169090/encoding-0.8.5/dist/setup/setup ...
Configuring encoding-0.8.5...
Preprocessing library for encoding-0.8.5..
arithmetic overflow
cabal: Failed to build encoding-0.8.5. See the build log above for details.
If I add --verbose=3 to the command line the last few output lines are
creating dist/build/Data
creating dist/build/Data/Encoding
Data/Encoding/ISO88592.hs generated from mapping
Data/Encoding/ISO88592.mapping
arithmetic overflow
CallStack (from HasCallStack):
die', called at ./Distribution/Client/ProjectOrchestration.hs:1041:55 in main:Distribution.Client.ProjectOrchestration
cabal: Failed to build
encoding-0.8.5-aa69e7dd952ebb6bcbe7b0947ad7f87838ecbfac327d0aa020c7f7f0f19b3e18.
I'm using cabal 3.2 and GHC 8.10.2 under Linux Mint 20.
I've looked "all over the place" for a solution, and the only trace of something similar is that the error is confirmed in Gentoo's Bugzilla.
Any help is appreciated!
This is apparently a bug in the library encoding (I could reproduce it), and there's a fix available as a PR on the source repository:
https://github.com/dmwit/encoding/pull/11
I'm trying to cabal install binary-strict and I get this error:
src/Data/Binary/BitBuilder.hs:205:37:
Ambiguous occurrence `unsafePerformIO'
It could refer to either `Foreign.unsafePerformIO',
imported from `Foreign' at src/Data/Binary/BitBuilder.hs:38:1-14
or `System.IO.Unsafe.unsafePerformIO',
imported from `System.IO.Unsafe' at src/Data/Binary/BitBuilder.hs:42:26-40
(and originally defined in `GHC.IO')
Failed to install binary-strict-0.4.8.1
cabal: Error: some packages failed to install:
binary-strict-0.4.8.1 failed during the building phase. The exception was:
ExitFailure 1
I'm running ghc 7.6.3. If it's relevant, I have binary-0.7.2.3 installed too.
As written, binary-strict only works for base >= 4.7. GHC 7.6.3 uses base = 4.6.* so it will not work. You should file a bug with the maintainer and work around the issue by adding hiding (unsafePerformIO) to the import Foreign line of the file in question.
I only just found out about this. It is now fixed. Also I have listed the git repo in the package details so you can now raise issues and I will know about them. Thanks to Thomas for suggesting the fix.
I'm working on a Linux machine with GHC 7.8.2 and cabal 1.20.0.1.
I'm trying to install semigroups and whenever I do, I get the dreaded error message about missing dyn_hi files.
/home/me/.cabal/lib/x86_64-linux-ghc-7.8.2/semigroups-0.14
setup-Simple-Cabal-1.18.1.3-x86_64-linux-ghc-7.8.2: Error: Could not find
module: Data.Semigroup with any suffix: ["dyn_hi"] in the search path:
["dist/build"]
cabal: Error: some packages failed to install:
semigroups-0.14 failed during the final install step. The exception was:
I've tried following the advice given here and here. I've removed .cabal/config, .ghc, added shared : True and followed each step.But after multiple repetitions of these instructions I'm still getting the same errors.
Is there any other way to diagnose and fix these errors?
I'm trying to install the regex-dfa package. I installed other regex packages like regex-tdfa, and they worked fine.
However, when I run sudo cabal install regex-dfa I get an error message:
Resolving dependencies...
[1 of 1] Compiling Main ( /tmp/regex-dfa-0.91-9125/regex-dfa-0.91/Setup.hs, /tmp/regex-dfa-0.91-9125/regex-dfa-0.91/dist/setup/Main.o )
Linking /tmp/regex-dfa-0.91-9125/regex-dfa-0.91/dist/setup/setup ...
Configuring regex-dfa-0.91...
Warning: No 'build-type' specified. If you do not need a custom Setup.hs or
./configure script then use 'build-type: Simple'.
Building regex-dfa-0.91...
Preprocessing library regex-dfa-0.91...
Text/Regex/DFA/Wrap.hs:1:16: Warning:
-fglasgow-exts is deprecated: Use individual extensions instead
<no location info>:
Failing due to -Werror.
Failed to install regex-dfa-0.91
cabal: Error: some packages failed to install:
regex-dfa-0.91 failed during the building phase. The exception was:
ExitFailure 1
What can I do about this?
The package is very old, the last (and the only) upload was in 2007. Don't use it if you can. Or contact the maintainer and ask him to update the package.
To fix this particular issue, you can cabal unpack regex-dfa, remove the -Werror and then cabal install it. But I'm not sure you will get another build error after that.
I am using Windows 7 with locale zh_CN and ghc-7.0.4
Default code page of the cmd.exe is 936.
> cabal install ghc-mod
Resolving dependencies...
Configuring ghc-syb-utils-0.2.1.0...
Preprocessing library ghc-syb-utils-0.2.1.0...
Building ghc-syb-utils-0.2.1.0...
<built-in>:0:4: lexical error (UTF-8 decoding error)
cabal: Error: some packages failed to install:
ghc-mod-1.10.7 depends on ghc-syb-utils-0.2.1.0 which failed to install.
ghc-syb-utils-0.2.1.0 failed during the building phase. The exception was:
ExitFailure 1
I have tried change code page and re-install again, but get the same output.
> chcp 65001
> cabal install ghc-mod
Some packages can be built successfully:
xml-1.3.12 textmath-0.6.0.3 tagsoup-0.12.6
Some packages would fail:
temporary-1.1.2.3 utf8-string-0.3.7 pandoc-types-1.9.0.2 json-0.5
I encountered the same problem.
I don't know if the cause is the same, but try
set LANG=C
before you run cabal. In my case, that fixed the problem.