簡體   English   中英

堆棧下的 ghc-mod 抱怨隱藏的主包

[英]ghc-mod under stack complaining about hidden main package

我有以下ghc-mod問題,這使我無法將 ide 用於yesod應用程序項目中的某些文件。

我安裝模板應用程序如下:

/tmp$ stack new demo yesod-sqlite && cd demo
/tmp/demo$ stack setup && stack build && stack install ghc-mod

其產生以下stack.yaml (已刪除注釋行):

resolver: lts-5.6
packages:
- '.'
extra-deps: []
flags: {}
extra-package-dbs: []

這是一個demo.cabalhttp : demo.cabal

然后,運行stack exec -- ghc-mod check app/main.hs不會產生錯誤,但是stack exec -- ghc-mod check app/devel.hs有這樣的說法:

app/devel.hs:2:1:Failed to load interface for ‘Application’It is a member of the hidden package ‘demo-0.0.0’.Perhaps you need to add ‘demo’ to the build-depends in your .cabal file.

所以ghc-mod以某種方式認為這個包本身是隱藏的? 但是任何其他地方的項目文件由另一個檢查導入的地方都很好,並且應用程序構建並成功運行。 關於這個文件的唯一細節是使用PackageImports語言擴展:

{-# LANGUAGE PackageImports #-}
import "demo" Application (develMain)

我嘗試使用谷歌搜索錯誤消息,但它似乎只與外部包有關,而不是正在調試的包。

這兩個文件devel.hsDevelMain.hs比較特殊:它們在.cabal被標記為demo的模塊,但它們是將demo作為編譯包導入,即遞歸依賴。

它們不會從庫demo公開,也不會從其他任何地方導入,因此在您運行stack build時不會被編譯,但是當您對它們運行ghc-mod check時,它們會在當前項目的上下文中被解釋,因此遞歸依賴將成為問題。


這兩個毫無意義的文件的唯一目的是在 ghci 中調試您的 yesod 網站,如DevelMain.hs的注釋所述:

-- | Running your app inside GHCi.
--
-- To start up GHCi for usage with Yesod, first make sure you are in dev mode:
--
-- > cabal configure -fdev
--
-- Note that @yesod devel@ automatically sets the dev flag.
-- Now launch the repl:
--
-- > cabal repl --ghc-options="-O0 -fobject-code"
--
-- To start your app, run:
--
-- > :l DevelMain
-- > DevelMain.update
--
-- You can also call @DevelMain.shutdown@ to stop the app
--
-- You will need to add the foreign-store package to your .cabal file.
-- It is very light-weight.
--
-- If you don't use cabal repl, you will need
-- to run the following in GHCi or to add it to
-- your .ghci file.
--
-- :set -DDEVELOPMENT
--
-- There is more information about this approach,
-- on the wiki: https://github.com/yesodweb/yesod/wiki/ghci

cabal replstack ghci將預先編譯項目,因此這兩個文件不會在那里導致任何錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM