Cabal error: invalid preprocessing directive #-} - haskell

$ cabal install arithmoi-0.4.0.3
results in multiple errors like:
Math/NumberTheory/Moduli.hs:489:4:
error: invalid preprocessing directive
#-}
^
My System:
OSX Mavericks
Cabal version = 1.18.1.1
GHCI version = 7.6.3
Thanks in advance!

Possible workaround here.
xCode 5 comes with clang as c/c++/obj-c compiler. Haskell Platform is not ready for that. The next ghc release will fix that.
Also see here.

Related

cabal install `gcc' failed in phase `C Compiler'

I want to use parsec for a personal project. But when I invoke cabal install parsec, I get an error:
clang: error: unknown argument: '-no-pie'
gcc' failed in phase `C Compiler'. (Exit code: 1)
I am on OS X El Capitan, 10.11.6. If I have understood correctly he error message above, gcc seems to be the cause. When I check the version of gcc, I get
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
Besides, I have read this `gcc.exe' failed in phase `C Compiler'. (Exit code: 1) and after stack setup--reinstall, stack install parsec worked very well. But cabal always not. Can you help me?
I had the same problem in the same time :-)
Most answers I’ve found on stackoverflow is about to update Xcode.
But! I’ve seen that suggestions since 2013, and in that case, I can’t update Xcode, because I have old Macbook and OS X 10.11 on it, i have tried:
brew install gcc
Next step I wondering how to setup Gnu C Compler over Xcode and found right now how.
Open in terminal with your fav. editor:
mate /Library/Frameworks/GHC.framework/Versions/8.4.2-x86_64/usr/lib/ghc-8.4.2/settings
And change this:
, ("C compiler command","gcc")
, ("C compiler flags"," -fno-stack-protector")
, ("C compiler link flags"," ")
, ("C compiler supports -no-pie","YES")
, ("Haskell CPP command","gcc")
with /usr/local/bin/gcc-8 instead gcc & "NO" instead "YES»
Hope it helps <3

Cabal: Failed to Install GLUtil

I'm new to Haskell but I want to try and write some OpenGL experiments in it.
I've successfully installed OpenGL, GLUT and a few other packages but when I attempt to install GLUtil I get the following error:
Building GLUtil-0.9.0.1...
Failed to install GLUtil-0.9.0.1
Build log ( C:\Users\David\AppData\Roaming\cabal\logs\GLUtil-0.9.0.1.log ):
Building GLUtil-0.9.0.1...
Preprocessing library GLUtil-0.9.0.1...
hpp: Couldn't open input file: -includeC:\Users\David\AppData\Local\Temp\ghc3236_0\ghc_2.h
CallStack (from HasCallStack):
error, called at src\Hpp\CmdLine.hs:89:0: error:
22 in hpp-0.3.0.0-61vdEFyxUJDaeEBxsHCsL:Hpp.CmdLine
`hpp' failed in phase `C pre-processor'. (Exit code: 1)
cabal: Leaving directory 'C:\Users\David\AppData\Local\Temp\cabal-tmp-6356\GLUtil-0.9.0.1'
cabal: Error: some packages failed to install:
GLUtil-0.9.0.1 failed during the building phase. The exception was:
ExitFailure 1
I tried using older versions of GLUtil and its dependencies but it always ended the same way and I eventually just cleared and reinstalled the Haskell Platform (I didn't know about sandboxing).
One thing that stands out is that -includeC:\Users\Dav... looks to me like a typo, as if there should be a space between -include and C:\... but I don't know how to change this. I couldn't find CmdLine.hs, just the interface file CmdLine.hi which yielded no results.
Does anyone have any advice on how to remedy this?
It appears that there should be a space between the -include and the file name.
I created a version of GLUtil-0.9.0.1 that is already preprocessed and should work for you:
https://github.com/erantapaa/GLUtil-0.9.0.1-no-cpp
It assumes you are using GHC 7.10.x or later.
The steps to remove the dependency on CPP were:
files JuicyTextures.hs and ShaderProgram.hs just use CPP to include Control.Applicative for older versions of GHC, so I just commented out those lines. Also remove CPP from the LANGUAGE pragma.
Linear.hs uses CPP to generate code. You can create the pre-processed output with:
gcc -E - < Linear.hs > new-Linear.hs
Then remove lines beginning with a hash (#) and remove CPP from the LANGUAGE pragma.
in GLUtil.cabal comment out/remove the lines:
if impl(ghc >= 7.10.1)
Build-depends: hpp >= 0.3 && < 0.4
GHC-Options: -pgmPhpp -optP--cpp -optP-P
else
Build-tools: cpphs
GHC-Options: -pgmPcpphs -optP--cpp -optP

Haskell cannot import GHC.SrcLoc

I can't get module "GHC.SrcLoc" in package "srcloc" on Ubuntu Haskell ...
-- "import" works on Windows, but not on Ubuntu 14.04
-- Module name is "GHC.SrcLoc"
-- Cabal build error below
Take 2: tried adding package "srcloc" to Cabal dependencies
^ Adding "srcloc" to dependencies causes "cabal configuration failed". ^
GHCI version...
$ ghci --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
Please help
https://hackage.haskell.org/package/base-4.8.2.0/docs/GHC-SrcLoc.html
My Haskell Code...
https://github.com/JohnReedLOL/HaskellPrintDebugger
* Attempt #1 *
:~/IdeaProjects/IntelliJHaskellPrintDebugger$ cabal install srcloc
Resolving dependencies...
All the requested packages are already installed:
srcloc-0.5.1.0
Use --reinstall if you want to reinstall anyway.
* Attempt #2 *
-- Tried replacing "import GHC.SrcLoc" with "import Data.Loc", but failed.
-- Tried adding "srcLock" to "build-depends" in .cabal, but failed.
^ Hopeless
Since Data.SrcLoc is a part of the GHC distribution and it wasn't added until (I believe) GHC 7.10.1, it will not exist in GHC 7.6.3. If you install the latest version of GHC, this should work fine.
The package you are seeing that is called srcloc appears to be unrelated to what you want, and does not provide the GHC.SrcLoc module. The GHC.SrcLoc module is instead provided by the GHC base standard library, which is included in (and requires) a newer version of GHC.
Newer versions of GHC also include a lot of other nice features that 7.6.3 (which was released more than 2 years ago) doesn't have.
You also mentioned stack traces, so you might be interested in this.
You must install the srcloc package; in the simple case where you are not using sandboxes, this is done by running cabal install srcloc at the command line.

ghc-modi and cabal version

(Haskell newbie here)
I'm trying to configure HaskForce plugin into IntelliJ IDEA, configured "ghc-mod" with "legacy-interactive" in "GHC Modi" Flags. The root problem seems to be related to cabal version, although when I try autocompleting on any Haskell symbol, I get this:
ghc-modi error
Unable to parse problems from ghc-modi: cabal-helper-wrapper.exe: ghc: readCreateProcess: does not exist (No such file or directory)
ghc-mod: readCreateProcess: C:\ACME\projects\htest\.cabal-sandbox\cabal-helper-0.5.3.0-553kah86RQN6BuDX6XLBiX\cabal-helper-wrapper.exe "C:\\ACME\\projects\\htest" "C:\\ACME\\projects\\htest\\dist" (exit 1): failed
When I run this last command (C:\ACME\projects\htest\.cabal-sandbox\cabal-helper-0.5.3.0-553kah86RQN6BuDX6XLBiX\cabal-helper-wrapper.exe "C:\\ACME\\projects\\htest" "C:\\ACME\\projects\\htest\\dist"), it tries to install cabal 1.18:
cabal-helper-wrapper.exe: Installing Cabal version 1.18.1.3 failed.
I already have cabal, of version 1.22 (installed via Haskell Platform v7.10.2-a, released recently in August).
Is there any way to work around this issue (i.e. still use ghc-mod / ghc-modi)?
Updated Haskforce plugin (0.3-beta24) seems to work correctly with following ghc-mod:
ghc-mod version 5.4.0.0 compiled by GHC 7.10.2

Persistent modules not found

I'm trying to use http://hackage.haskell.org/package/persistent-1.2.3.0, but after installing it through "cabal install persistent", ghc doesn't find its exposed-modules:
Prelude> import Database.Persist.Types
<no location info>:
Could not find module `Database.Persist.Types'
It is not a module in the current program, or in any known package.
And ghc-pkg works fine:
$ ghc-pkg find-module Database.Persist.Types
/var/lib/ghc/package.conf.d
/home/apsk/.ghc/x86_64-linux-7.6.3/package.conf.d
persistent-1.2.3.0
Am I missing something or is this just a bug with cabal/persistent/ghc? My ghc is 7.6.3, btw.
Also, I've tried with no effect: "ghc-pkg recache"; "ghc-pkg check"; installing previous version; reinstalling with and without "sudo" and/or "--global".
Check that you're not using sandboxes, cabal-dev, hsenv, anything else that can influence ghc in looking for dependencies. Make sure you're using ghc/ghci, and not any wrappers, and that ghc/ghci are not aliased to anything in your shell.
Try to specify the package-db explicitly:
ghci -package-db /home/apsk/.ghc/x86_64-linux-7.6.3/package.conf.d
If you launch ghci with -v, it'll print the (caches of) databases it looks at, like this:
% ghci -v
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Glasgow Haskell Compiler, Version 7.6.3, stage 2 booted by GHC version 7.4.2
Using binary package database: /opt/ghc763/lib/ghc-7.6.3/package.conf.d/package.cache
Using binary package database: /home/feuerbach/.ghc/i386-linux-7.6.3/package.conf.d/package.cache
Make sure that the database which has persistent is listed there.
Hopefully helpful to someone. Using ghci -v I looked to see if persistent was there, and saw this:
package persistent-2.0.8-cec952b1a61645f47dbec3b0b0cbcef4 is unusable due to missing or recursive dependencies: aeson-0.8.0.0-1bd8b5254a1dd30c0fe6acc346ad7de7 attoparsec-0.12.1.2-48393fcdbcf426085b696dc4409d9270 conduit-1.2.0.2-39f9cd0430ed7b7f4306899cbeb1ed83 monad-logger-0.3.7.2-3e6a80e9b3adf31497ff04514bdf2919 resource-pool-0.2.3.0-c02186641e7173f72887d5e65a646ac1 scientific-0.3.3.1-13e0eefbd7215e4503420c3d0a6fdb82 unordered-containers-0.2.5.0-147c3bb8f4a2da7d753455e75af30b92
So I looked around on SO (saw this: Haskell Cabal: Mysterious missing or recursive dependencies) but didn't find a great answer. I did find a good one here though:
$ ghc-pkg list Cabal
Which revealed I had 2 goddamn cabals! One in user and one in global. Ugh. So I was able to do ghc-pkg unregister --user Cabal-1.18.1.3 --force to get rid of the old one. Then cabal install cabal automatically went for 1.20, implicitly into user without any flag (the alternate would be --global).
The problem only occurs in GHCi, right? Have you restarted GHCi since installing persistent? (Maybe there's another way to get GHCi to pick up newly installed packages, but I'm not aware of it.

Resources