I am trying to get a project running that uses conduit and conduit-extra. This is the main module:
import Data.Conduit
main = do
putStrLn "Done"
The cabal file requires base, conduit and conduit-extra:
...
build-depends: base >=4.8 && <4.9,
conduit >=1.2.5 && <1.3,
conduit-extra >= 1.1.9.1 && <1.2
...
Yet when I run cabal repl, this happens:
Johns-iMac:The-Project john$ cabal repl
Preprocessing executable 'The-Project' for The-Project-0.1.0.0...
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help
<command line>: can't load .so/.DLL for: /Library/Haskell/ghc-7.10.2-x86_64/lib/exceptions-0.8.0.2/libHSexceptions-0.8.0.2-8GsEeHgaIks3pVGk6GaELJ-ghc7.10.2.dylib (dlopen(/Library/Haskell/ghc-7.10.2-x86_64/lib/exceptions-0.8.0.2/libHSexceptions-0.8.0.2-8GsEeHgaIks3pVGk6GaELJ-ghc7.10.2.dylib, 5): Library not loaded: #rpath/libHStransformers-compat-0.4.0.4-DCQioW2d4vYEa3T0AmFBPv-ghc7.10.2.dylib
Referenced from: /Library/Haskell/ghc-7.10.2-x86_64/lib/exceptions-0.8.0.2/libHSexceptions-0.8.0.2-8GsEeHgaIks3pVGk6GaELJ-ghc7.10.2.dylib
Reason: image not found)
I just completely reinstalled the Haskell Platform, and it's all sandboxed, so there shouldn't be any problems with competing dependencies.
What is happening, and how do I fix it?
UPDATE:
I deleted the sandbox (cabal.sandbox.config, .cabal-sandbox), and reinstalled the dependencies:
cabal sandbox init
cabal install --only-dependencies
cabal repl
We now have a new but very similar error:
Johns-iMac:The-Project john$ cabal repl
Preprocessing executable 'The-Project' for The-Project-0.1.0.0...
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help
<command line>: can't load .so/.DLL for: /Library/Haskell/ghc-7.10.2-x86_64/lib/hashable-1.2.3.3/libHShashable-1.2.3.3-2GTZqecVp8NJZrNuKzGxfy-ghc7.10.2.dylib (dlopen(/Library/Haskell/ghc-7.10.2-x86_64/lib/hashable-1.2.3.3/libHShashable-1.2.3.3-2GTZqecVp8NJZrNuKzGxfy-ghc7.10.2.dylib, 5): Library not loaded: #rpath/libHStext-1.2.1.3-1l1AN4I48k37RaQ6fm6CEh-ghc7.10.2.dylib
Referenced from: /Library/Haskell/ghc-7.10.2-x86_64/lib/hashable-1.2.3.3/libHShashable-1.2.3.3-2GTZqecVp8NJZrNuKzGxfy-ghc7.10.2.dylib
Reason: image not found)
Given that this report refers to a problem loading hashable, and the Github report refers to a problem loading exceptions, both of which are packages provided by the platform and not GHC, I have a feeling there's a problem with the platform installer. Can you try again with either GHC for Mac OS X or stack and see if it resolves the issue?
Note that, if you go the stack route, you'll want to run stack init && stack build --install-ghc && stack ghci in your project. In either case: you'll probably be safer if you completely remove the platform install first.
Related
This must be very simple; but why this error:
PS C:\Users\guthrie\Desktop> cabal install --lib timeit
Resolving dependencies...
Up to date
PS C:\Users\guthrie\Desktop> ghci
GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
Prelude> :m System.TimeIt
<no location info>: error:
Could not find module `System.TimeIt'
Perhaps you meant System.Timeout (from base-4.14.1.0)
Prelude>
Leaving GHCi.
Hackage shows System.TimeIt as being defined in timeit-2.0, which is what cabal installed.
PS C:\Users\guthrie\Desktop> cabal install timeit
Resolving dependencies...
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
- timeit-2.0 (lib) (requires download & build)
Downloading timeit-2.0
Downloaded timeit-2.0
Starting timeit-2.0 (lib)
Building timeit-2.0 (lib)
Installing timeit-2.0 (lib)
Completed timeit-2.0 (lib)
Checking again:
PS C:\Users\guthrie\Desktop> cabal install --lib timeit
Resolving dependencies...
Up to date
But trying to check on it from cabal info::
PS C:\Users\guthrie\Desktop> cabal info timeit
* timeit (library)
Synopsis: Time monadic computations with an IO base.
Versions available: 0.9.0.0, 1.0.0.0, 2.0
Versions installed: [ Not installed ]
Homepage: https://github.com/merijn/timeit
Bug reports: https://github.com/merijn/timeit/issues
Description: A simple wrapper to show the used CPU time of monadic
computation with an IO base.
Category: System
License: BSD3
Author: Lennart Augustsson
Maintainer: Merijn Verstraaten <merijn#inconsistent.nl>, Lennart Augustsson
Source repo: ssh://github.com:merijn/timeit.git
Dependencies: base >=3 && <5, transformers >=0.2 && <0.6
Cached: Yes
Modules:
System.TimeIt
So it reports: "Not installed".
Same problem with criterion (Criterion.Main).
I see a note from 2/2020; that if a package is installed without the --lib option,
It does add the library to the package db in this case but does not
add it to the default environment.
(*https://github.com/haskell/cabal/issues/6262#issuecomment-589843722)
So I repeated the install with this option, no effect - just reported "Up to date".
That same link gave a solution (work-around?) to use instead cabal v1-install, which does work. But what would be the recommended simple solution to be able just to use ghci for testing small codes? Forced migration to stack, with local sandboxed and copies of everything for every small test?
Since I am only doing very simple short tests of examples, I was not creating a sandbox for each, and do not have a .cabal file, are those now necessary?!
(cabal 3.2.0.o, ghc 8.10.2, Windows 10)
I strongly recommend that you don't try to use ghc and ghci directly but instead use cabal. If you want to quickly play around with timeit in the REPL then use
cabal v2-repl --build-depends timeit
If you want to do anything more complicated then create a (perhaps temporary) project and add timeit as a dependency:
$ mkdir my-temporary-package
$ cd my-temporary-package
$ cabal init
Edit my-temporary-package.cabal to change
build-depends: base >=... && <...
to
build-depends: base, timeit
(The constraints on base are going to cause you more harm than good for a quick exploratory project. You can add them back later if it becomes necessary.) Then
$ cabal v2-repl
will get you a REPL with timeit available.
I want to add the bound library to my package dependencies;
The project is completely fresh initialized with stack new.
The entry in the cabal file looks like this:
executable DependendLambda-exe
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base
, DependendLambda
, bound
default-language: Haskell2010
I get the following error message:
While constructing the build plan, the following exceptions were encountered:
In the dependencies for DependendLambda-0.1.0.0:
bound must match -any, but the stack configuration has no specified
version (latest applicable is 1.0.7)
Recommended action:
try adding the following to your extra-deps in /home/MyProject/stack.yaml:
- bound-1.0.7
You may also want to try the 'stack solver' command
Plan construction failed.
Warning: build failed, but optimistically launching GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Using main module: 1. Package `DependendLambda' component exe:DependendLambda-exe with main-is file: /home/MyProject/app/Main.hs
Configuring GHCi with the following packages: DependendLambda
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
<command line>: cannot satisfy -package bound
(use -v for more information)
When I add the dependency to extra-deps it is still failing:
While constructing the build plan, the following exceptions were encountered:
In the dependencies for bound-1.0.7:
binary-0.8.3.0 must match >=0.5 && <0.8 (latest applicable is 0.7.6.1)
comonad-5 must match >=3 && <5 (latest applicable is 4.3)
transformers-0.5.2.0 must match >=0.2 && <0.5 (latest applicable is 0.4.3.0)
needed due to DependendLambda-0.1.0.0 -> bound-1.0.7
Plan construction failed.
Warning: build failed, but optimistically launching GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Using main module: 1. Package `DependendLambda' component
exe:DependendLambda-exe with main-is file: /home/MyProject/app/Main.hs
Configuring GHCi with the following packages: DependendLambda
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
<command line>: cannot satisfy -package bound-1.0.7
(use -v for more information)
The stack solver command didn't help either ... what am I missing?
Thanks for your help!
Is there a way to load a package(s) using Stack in GHCI and play around with it ?
So, that when the ghci is loaded, we can import the modules and see it's type signature, etc.
For the packages present in Stackage,
$ stack ghci --package unix-time
And this will give you a repl with the package unix-time loaded in it:
Run from outside a project, using implicit global project config
Using resolver: lts-6.14 from implicit global project's config file: /home/sibi/.stack/global-project/stack.yaml
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
λ> import Data.UnixTime
λ> :t getUnixTime
getUnixTime :: IO UnixTime
For multiple packages:
$ stack ghci --package unix-time --package download
Run from outside a project, using implicit global project config
Using resolver: lts-6.14 from implicit global project's config file: /home/sibi/.stack/global-project/stack.yaml
tagsoup-0.13.10: using precompiled package
xml-1.3.14: using precompiled package
time-locale-compat-0.1.1.3: using precompiled package
feed-0.3.11.1: download
feed-0.3.11.1: configure
feed-0.3.11.1: build
feed-0.3.11.1: copy/register
download-0.3.2.4: download
download-0.3.2.4: configure
download-0.3.2.4: build
download-0.3.2.4: copy/register
Completed 5 action(s).
Configuring GHCi with the following packages:
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
Ok, modules loaded: none.
λ> import Network.Download
λ>
I installed diagrams, and it seems to be there, but GHCi doesn’t find it. I tried adding the local sandbox to the command line (-package-db), but still no luck.
Any suggestions?
C:\Users\guthrie>
C:\Users\guthrie>cabal install diagrams
Resolving dependencies...
All the requested packages are already installed:
diagrams-1.2
Use --reinstall if you want to reinstall anyway.
I find it in:
C:\Users\guthrie\.cabal-sandbox\i386-windows-ghc-7.6.3-packages.conf.d
(diagrams-1.2, diagrams-contrib, -core, -lib, -svg)
But running: “cabal repl” or using the GHC(i) flag “-package-db=…”
fail to find it:
C:\Users\guthrie>cabal repl
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m + Diagrams.Prelude
<no location info>:
Could not find module `Diagrams.Prelude'
It is not a module in the current program, or in any known package.
Prelude>
To clarify; ignoring the cabal invocations, using GHC/i directly, and the program diagramsDemo.hs:
-- http://projects.haskell.org/diagrams/doc/quickstart.html
--
import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine
main = mainWith (circle 1 :: Diagram B R2)
Gives:
C:\Users\guthrie\Desktop\xFer\Graphics>ghc --make diagramsDemo.hs
diagramsDemo.hs:7:8:
Could not find module `Diagrams.Backend.SVG.CmdLine'
Use -v to see a list of the files searched for.
C:\Users\guthrie\Desktop\xFer\Graphics>ghc --make diagramsDemo.hs -package-db=C:\Users\guthrie\.cabal-sandbox\i386-windows-ghc-7.6.3-packages.conf.d
diagramsDemo.hs:7:8:
Could not find module `Diagrams.Backend.SVG.CmdLine'
Use -v to see a list of the files searched for.
As bheklilr said, if ghci is started with cabal repl, it will only find packages specified as a dependency in the .cabal file.
However you can start it with cabal exec ghci, then it will find all packages installed in the sandbox.
The same is true for invoking ghc (cabal build vs. cabal exec ghc), but note that if you want to pass flags you have to use --, like in cabal exec ghc -- -O2 Main.hs. Alternatively you can use cabal exec bash and launch ghci or ghc in the new shell.
cabal exec was added with Cabal 1.20.
I installed diagrams, and it seems to be there, but GHCi doesn’t find it. I tried adding the local sandbox to the command line (-package-db), but still no luck.
Any suggestions?
C:\Users\guthrie>
C:\Users\guthrie>cabal install diagrams
Resolving dependencies...
All the requested packages are already installed:
diagrams-1.2
Use --reinstall if you want to reinstall anyway.
I find it in:
C:\Users\guthrie\.cabal-sandbox\i386-windows-ghc-7.6.3-packages.conf.d
(diagrams-1.2, diagrams-contrib, -core, -lib, -svg)
But running: “cabal repl” or using the GHC(i) flag “-package-db=…”
fail to find it:
C:\Users\guthrie>cabal repl
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m + Diagrams.Prelude
<no location info>:
Could not find module `Diagrams.Prelude'
It is not a module in the current program, or in any known package.
Prelude>
To clarify; ignoring the cabal invocations, using GHC/i directly, and the program diagramsDemo.hs:
-- http://projects.haskell.org/diagrams/doc/quickstart.html
--
import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine
main = mainWith (circle 1 :: Diagram B R2)
Gives:
C:\Users\guthrie\Desktop\xFer\Graphics>ghc --make diagramsDemo.hs
diagramsDemo.hs:7:8:
Could not find module `Diagrams.Backend.SVG.CmdLine'
Use -v to see a list of the files searched for.
C:\Users\guthrie\Desktop\xFer\Graphics>ghc --make diagramsDemo.hs -package-db=C:\Users\guthrie\.cabal-sandbox\i386-windows-ghc-7.6.3-packages.conf.d
diagramsDemo.hs:7:8:
Could not find module `Diagrams.Backend.SVG.CmdLine'
Use -v to see a list of the files searched for.
As bheklilr said, if ghci is started with cabal repl, it will only find packages specified as a dependency in the .cabal file.
However you can start it with cabal exec ghci, then it will find all packages installed in the sandbox.
The same is true for invoking ghc (cabal build vs. cabal exec ghc), but note that if you want to pass flags you have to use --, like in cabal exec ghc -- -O2 Main.hs. Alternatively you can use cabal exec bash and launch ghci or ghc in the new shell.
cabal exec was added with Cabal 1.20.