私はHaskellバージョン7.8.4を(X)Ubuntu 15.10で、Cabal-Install 1.18を両方ともapt
からインストールして使用しています。私は、このマシンにHaskell関連のものを手作業でインストールしようとはしませんでした。私はcabalサンドボックスをセットアップし、取り出して、ghc
がそれを拾うように見えないことを発見するためだけにモジュールをインストールしました。 ghc -v
は、互いに陰影をつけているカバールライブラリの2つのバージョンがあることを示唆しているようです。これはどのように作動しますか?GHCがCabal Sandboxのモジュールを見つけることができません
私はその後、私はcabal sandbox init
を行う空のディレクトリ/tmp/haskell-example
で出始めています。
$ cabal sandbox init
Writing a default package environment file to
/tmp/haskell-example/cabal.sandbox.config
Creating a new sandbox at /tmp/haskell-example/.cabal-sandbox
私はプログラムでData.Natural
モジュールを使用したいので、私はnatural-numbers
をインストールします。この操作は成功します。
$ cabal install natural-numbers
Resolving dependencies...
Notice: installing into a sandbox located at
/tmp/haskell-example/.cabal-sandbox
Configuring natural-numbers-0.1.2.0...
Building natural-numbers-0.1.2.0...
Installed natural-numbers-0.1.2.0
私はData.Natural
モジュールが実際に秘密結社サンドボックスにインストールされていることを確認することができます。
$ ls /tmp/haskell-example/.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/natural-numbers-0.1.2.0
Data
libHSnatural-numbers-0.1.2.0.a
libHSnatural-numbers-0.1.2.0-ghc7.8.4.so
$ ls /tmp/haskell-example/.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/natural-numbers-0.1.2.0/Data
Natural.dyn_hi
Natural.hi
はその後、私はData.Natural
をインポートし、それを使用しない単純なMain.hs
ファイルを作成します。
module Main where
import Data.Natural
main = putStrLn "Hello World"
私はghc Main.hs
にしようとすると、私は以下を参照してください。
$ ghc Main.hs
Main.hs:3:8:
Could not find module ‘Data.Natural’
Use -v to see a list of the files searched for.
有効に冗長フラグで私の秘密結社がシャドウイング順番にある後の徒党によって影になっているかのように、それはそうです以前のカバール。なぜこうなった?
$ ghc -v Main.hs
Glasgow Haskell Compiler, Version 7.8.4, stage 2 booted by GHC version 7.8.4
Using binary package database: /usr/lib/ghc/package.conf.d/package.cache
hiding package Cabal-1.18.1.5 to avoid conflict with later version Cabal-1.22.1.1
wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-ec14d2f6075975a2ce9112eae431c8e1
wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-de4898ebdc5ab81cedce89121ae9ac84
wired-in package base mapped to base-4.7.0.2-5ef1e7e809bc3b18d74efc783356e209
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.9.0.0-c1976a420ad8b9b589eee08844c59ba2
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags:
hiding package Cabal-1.18.1.5 to avoid conflict with later version Cabal-1.22.1.1
wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-ec14d2f6075975a2ce9112eae431c8e1
wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-de4898ebdc5ab81cedce89121ae9ac84
wired-in package base mapped to base-4.7.0.2-5ef1e7e809bc3b18d74efc783356e209
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.9.0.0-c1976a420ad8b9b589eee08844c59ba2
wired-in package dph-seq not found.
wired-in package dph-par not found.
*** Chasing dependencies:
Chasing modules from: *Main.hs
Main.hs:3:8:
Could not find module ‘Data.Natural’
Locations searched:
Data/Natural.hs
Data/Natural.lhs
*** Deleting temp files:
Deleting:
*** Deleting temp dirs:
Deleting:
.cabalファイルを更新しましたか? – Sigrlami
@Sigrlami私は理解していないのが怖いです。 '$ HOME/.cabal'と'/tmp/haskell-example/.cabal-sandbox'というディレクトリがありますが、 '.cabal'ファイルはありません。私はそれを更新するために何をする必要がありますか? –
プロジェクト内で 'cabal init'コマンドを使用しているときは、必要なすべての依存関係を記述する' foo.cabal'ファイルを作成しており、それらを手動で追加する必要があります。あなたのプロジェクト名は 'foo'と仮定します。たとえば、https://github.com/sigrlami/pollock/blob/master/pollock.cabal – Sigrlami