Haskell Plugins and cabal sandbox - haskell

So, I'm trying to use the Plugins package to dynamically load a haskell function from a source file. The source file depends on a package foo with module Foo.Bar. I'm running my project in a Cabal sandbox, where I have foo installed. Both my main program, and the module I'm loading with plugins, depend on foo. I always get one of the following two errors:
When I have foo installed in ~/.cabal, I get the error:
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
aizmvszmaizmlibzm0zi1_FooziBar_zdfTypeableBazzuds2_closure
whilst processing object file
/home/joey/.cabal/lib/foo-0.1/ghc-7.6.3/HSfoo-0.1.o
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
When I don't have it installed in ~/.cabal, I get a standard "module not found" error. And when I don't have it installed in my sandbox, I get the same module not found error trying to compile my main program code.
The plugins documentation is scarce at best. Any thoughts on how to solve this?

I got this working by using System.Plugins.Make to actually do the compliation, instead of relying on pre-existing object files. Not a complete solution, doesn't explain the problem, but it works for me for now.

Related

Cabal update now can't load any modules from "hidden packages"

I've been working on a project and recently I did a cabal update.
I usually roll into ghci like:
$ ghci -package-db ~/.cabal/store/ghc-8.10.7/package.db
After the update loading module in my project results in even the basic Haskell modules like System.Random or MonadIO fails with the following errors when trying to load my own module called ProcessIO:
ProcessIO.hs:50:1: error:
Could not load module ‘Data.IORef.MonadIO’
It is a member of the hidden package ‘monadIO-0.11.1.0’.
You can run ‘:set -package monadIO’ to expose it.
(Note: this unloads all the modules in the current scope.)
Locations searched:
Data/IORef/MonadIO.hs
Data/IORef/MonadIO.lhs
Data/IORef/MonadIO.hsig
Data/IORef/MonadIO.lhsig
I checked that maybe the .cabal file build-depends versions might have been altered, but the cabal package.db directory contains all the right versions of the dependencies in the .cabal file. For example the error above complains abot monadIO-0.11.1.0 being hidden however: in package.db/ we see the right version exists:
monadIO-0.11.1.0-0aec75273f3fef94783e211a1933f8ac923485a963be3b6a61995d4a88dd1135.conf
I should say I haven't looked at the package.db files before because everything simple worked so there may be something telling about the .conf file name that signals something is wrong.
Either way, can't build anything and I need some help!
EDIT: posting my default environments file ~/.ghc/x86_64-linux-8.10.7/environments/default in case it matters:
clear-package-db
global-package-db
package-db /home/surya/.cabal/store/ghc-8.10.7/package.db
package-id ghc-8.10.7
package-id bytestring-0.10.12.0
...
(Let me know if I need to share more of it... or less)

Yesod build error because of the duplicate definition for symbol "hsprimitive_memcpy"

I followed "Yesod quick start guide" to install Yesod in Windows 10.
But, when I issued the stack build command, it failed.
Environment
Windows 10 (64bits)
stack-0.1.5 (for Windows10 64bits)
Haskell Platform 7.10.2-a (from HaskellPlatform-7.10.2-a-x86_64-setup.exe)
alex-3.1.4.log
GHC runtime linker: fatal error: I found a duplicate definition for symbol
hsprimitive_memcpy
whilst processing object file
C:\Users\xxxxx\AppData\Roaming\stack\snapshots\x86_64-windows\lts-3.8\7.10.2\lib\x86_64-windows-ghc-7.10.2\primitive-0.6.1.0-5Jnw7oEuYtM9dmKXelGXVb\HSprimitive-0.6.1.0-5Jnw7oEuYtM9dmKXelGXVb.o
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
ghc: panic! (the 'impossible' happened)
(GHC version 7.10.2 for x86_64-unknown-mingw32):
loadObj "C:\\Users\\xxxxx\\AppData\\Roaming\\stack\\snapshots\\x86_64-windows\\lts-3.8\\7.10.2\\lib\\x86_64-windows-ghc-7.10.2\\primitive-0.6.1.0-5Jnw7oEuYtM9dmKXelGXVb\\HSprimitive-0.6.1.0-5Jnw7oEuYtM9dmKXelGXVb.o": failed
It seems that the cause of the error were the duplicated GHC installation.
Thanks for #Reid comment, I realized that I installed Haskel Platform from exe file before and I also installed GHC through stack by folloing the guide.
I unisatlled GHC of Haskel Platform and executed 'stack setup' command.
Then, I executed 'stack build' command and it seemed worked.
I still have problems with the 'stack build' command, but I solved this issue.

GHC error: Cannot continue after interface file error

I have a Haskell package that is built and installed with Cabal. Running cabal repl in the package directory works perfectly, all the module imports work, etc. When I try to use the package in another directory, imports do not complain, but when I try to use a function from the file, I get this error in GHCi
λ> import Data.Frame
λ> import Data.Frame.CSV
λ> :t fromCsvHeaders
/Users/Stian/.cabal/lib/x86_64-osx-ghc-7.8.3/frame-0.1.0.0/Data/Frame/CSV.dyn_hi
Declaration for fromCsvHeaders:
Failed to load interface for ‘Data.Frame.Internal’
Perhaps you haven't installed the "dyn" libraries for package ‘frame-0.1.0.0’?
Use -v to see a list of the files searched for.
Cannot continue after interface file error
The same happens when running ghc.
Turns out in this case there was an internal module that had not been exposed in the cabal file.

Cabal: rebuild package to use newer libraries

I'm using Ubuntu 14.10 with GHC 7.6.3 and cabal installed via the Ubuntu package installer, and trying to use the Heap data structure, which I naively installed using:
cabal install heap
As soon as I started importing the library into my code, I got the following linking error:
...
Loading package primitive-0.5.0.1 ... linking ... done.
...
Loading package heap-1.0.0 ... linking ... done.
...
Loading package primitive-0.5.2.1 ... linking ... done
...
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
hsprimitive_memset_Word32
whilst processing object file
/home/simon/.cabal/lib/primitive-0.5.2.1/ghc-7.6.3/HSprimitive-0.5.2.1.o
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
This answer notionally explains what to do, but the instructions are not specific enough for me to follow.
How do I get Heap to use primitive-0.5.2.1 (I'm assuming that this lightly used library is the one that is out of date), or should I be doing something completely different?
One solution might be to specifically install an earlier version of heap:
cabal install heap-0.6.0
You might have to first unregister heap-1.0.0.
Another option is to blow away your ~/.ghc directory. Of course, you will have to reinstall cabal packages.
I think the best option is to start using cabal sandboxing for your projects.
Edit: heap-1.0.0 contains QuickCheck tests and thus brings in all of the QuickCheck dependencies. To install that version without QuickCheck, try this:
In a new directory, run cabal get heap-1.0.0
cd heap-1.0.0
Edit heap.cabal and remove the Build-Depends: line
Run cabal install

Duplicate definition for symbol

I'm trying to compile a package (git-annex) under OpenBSD and I'm hitting some weird issues.
I keep getting
Loading package gnuidn-0.2.1 ...
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
c_isascii
whilst processing object file
/usr/local/lib/libidn.a
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
This was brought up here, here and here but it didn't help me at all. I have checked to see if I have different versions of different packages (which I don't, according to ~/.cabal/lib and 'ghc-pkg list') and I have even tried recompiling libidn without the c_isascii symbol, which only resulted in the same error but about a different symbol (stringprep_utf8_to_unichar).
So right now I have no idea what to do. Any ideas?
EDIT: Added 'ghc-pkg list' to the sources I've checked for conflicting packages.

Resources