2016-12-26 73 views
2

我使用stack new project yesod-postgres創建了Yesod應用程序。除了Web應用程序之外,我還想創建另一個使用相同數據庫模型和數據庫連接的程序。如何根據Yesod應用程序構建程序

我在cabal文件中添加了第二個executable部分(第一個副本),其名稱不同,main-is: myprogram.hs。我現在可以成功運行stack build && stack exec myprogram

的問題是,構建始終以超過1分鐘:

$ stack build 
project-0.0.0: unregistering 
yesod-persistent-1.4.0.6: configure 
yesod-persistent-1.4.0.6: build 
yesod-persistent-1.4.0.6: copy/register 
yesod-form-1.4.9: configure 
yesod-form-1.4.9: build 
yesod-form-1.4.9: copy/register 
yesod-auth-1.4.15: configure 
yesod-auth-1.4.15: build 
yesod-auth-1.4.15: copy/register 
yesod-1.4.3.1: configure 
yesod-1.4.3.1: build 
yesod-1.4.3.1: copy/register 
classy-prelude-yesod-0.12.8: configure 
classy-prelude-yesod-0.12.8: build 
classy-prelude-yesod-0.12.8: copy/register 
project-0.0.0: build 
Preprocessing library project-0.0.0... 
In-place registering project-0.0.0... 
Preprocessing executable 'myprogram' for project-0.0.0... 
Linking .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/myprogram/myprogram ... 
Preprocessing executable 'project' for project-0.0.0... 
Linking .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/project/project ... 
project-0.0.0: copy/register 
Installing library in 
/home/jakob/projects/project/project/.stack-work/install/x86_64-linux/lts-6.27/7.10.3/lib/x86_6 
4-linux-ghc-7.10.3/project-0.0.0-1qruVQVcU0k2yXxF1Z1w7r 
Installing executable(s) in 
/home/jakob/projects/project/project/.stack-work/install/x86_64-linux/lts-6.27/7.10.3/bin 
Registering project-0.0.0... 
Completed 6 action(s). 

我如何可以加快構建過程?我怎樣才能防止堆棧每次重建yesod依賴關係?

回答

3

這不是特定於添加第二個可執行文件;它甚至發生在具有單個可執行文件的新項目yesod-postgres中。

相反,它似乎是Stack的lts-6.27軟件包集合(可能還有其他?)中的一個錯誤。這是一個解決方法。在你stack.yaml,添加以下額外-DEP:

extra-deps: 
- yesod-persistent-1.4.0.6 

和運行stack build。然後,第二個stack build應該運行而不重建任何東西。

+0

作爲[Stack issue 2876]提交(https://github.com/commercialhaskell/stack/issues/2876)。 –

+0

工作正常!感謝您和+1提交錯誤。 – schoettl