I created a Yesod application using stack new project yesod-postgres. Beside the web application, I want to create another program which uses the same database model and database connection.
I added a second executable section (a copy of the first) in the cabal file with a different name and main-is: myprogram.hs. I can now run stack build && stack exec myprogram successfully.
The problem is that the build always takes more than 1 minute:
$ 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).
How can I speed up the build process? How can I prevent stack from rebuilding the yesod dependencies every time?
This isn't specific to adding a second executable; it happens even with a fresh yesod-postgres project with a single executable.
Instead it appears to be a bug in Stack's lts-6.27 package set (and possibly others?). Here's a workaround. In your stack.yaml, add the following extra-dep:
extra-deps:
- yesod-persistent-1.4.0.6
and run stack build. Then, a second stack build should run without rebuilding anything.
Related
I'm unable to do stack build for any projects on Ubuntu 20.04 or 18.04 running as a VirtualBox guest on Windows 10. Building fails when trying to rename a temp file: .stack-cabal-mod11115-0.tmp: rename: resource busy (Text file busy)
edit: this appears to only happen on VirtualBox shared folders. Stack can successfully build a project in a folder that is not shared with the Windows hot.
I've previously had no issues with 1.9.x versions of stack in identical environments. At this point I'm not even able to get stack build to compile a new project on a clean Ubuntu installation. If I downgrade to 1.9.3 everything magically works. I've deleted ~.stack and .stack-work folders and retried without success.
Below is the output on a new project using stack new. I'm able to use stack repl, although I still get an error message about the build failing with
vagrant#ubuntu-focal:/vagrant/test$ stack --version
Version 2.7.1, Git revision 8afe0c2932716b0441cf4440d6942c59568b6b19 x86_64 hpack-0.34.4
vagrant#ubuntu-focal:/vagrant/test$ stack setup
Preparing to install GHC (tinfo6) to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-tinfo6-8.10.4.
Installed GHC.
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
vagrant#ubuntu-focal:/vagrant/test$ stack build
[1 of 2] Compiling Main ( /home/vagrant/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /home/vagrant/.stack/setup-exe-src/setup-mPHDZzAJ.o )
[2 of 2] Compiling StackSetupShim ( /home/vagrant/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /home/vagrant/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o )
Linking /home/vagrant/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4 ...
Building all executables for `test' once. After a successful build of all of them, only specified executables will be rebuilt.
test> configure (lib + exe)
Configuring test-0.1.0.0...
/vagrant/test/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/.stack-cabal-mod11009-2.tmp: rename: resource busy (Text file busy)
vagrant#ubuntu-focal:/vagrant/test$ stack build
Building all executables for `test' once. After a successful build of all of them, only specified executables will be rebuilt.
test> configure (lib + exe)
Configuring test-0.1.0.0...
/vagrant/test/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/.stack-cabal-mod11115-0.tmp: rename: resource busy (Text file busy)
Thanks.
I'm now learning hakyll static site generator with stack.
When I execute stack build in the directory of my Hakyll site to rebuild site.hs, stack also rebuilds and copy/register dependencies each time, as shown below:
$ stack --version
Version 1.6.5, Git revision 24ab0d6ff07f28276e082c3ce74dfdeb1a2ca9e9 (5514 commits) x86_64 hpack-0.20.0
$ grep -Ev '^[[:space:]]*#' stack.yaml | uniq
resolver: lts-11.4
packages:
- .
$ stack build
haddock-library-1.4.5: configure
haddock-library-1.4.5: build
haddock-library-1.4.5: copy/register
pandoc-2.1.2: configure
pandoc-2.1.2: build
pandoc-2.1.2: copy/register
pandoc-citeproc-0.14.3: configure
pandoc-citeproc-0.14.3: build
pandoc-citeproc-0.14.3: copy/register
hakyll-4.12.1.0: configure
hakyll-4.12.1.0: build
hakyll-4.12.1.0: copy/register
... and site.hs.compilation ...
This is odd to me, because I have never changed those packages.
The rebuild takes quite long even for very small changes on site.hs.
Why does stack rebuild those packages? And is there any way to reduce this rebuild time?
Thank you.
There is a discussion of this here https://github.com/commercialhaskell/stack/issues/3899 . It's a known issue triggered by newer versions of haddock using sub-libraries. There's a PR open fixing the issue, but it hasn't been merged yet.
I'm following these instructions. I successfully did stack new and stack setup but stack build fails.
I found a git issue that this may be due to extra files listed in the cabal file, but removing them didn't fix the issue (and I'm just using the new-template without any changes). I am on Ubuntu 14.04 and installed stack using the script. Is there anything else I can look into?
It appears that this might be due to me trying to build inside of a cifs directory. Is there anything I can do to handle this?
# stack build
ehri-haskell-0.1.0.0: configure (lib + exe)
Configuring ehri-haskell-0.1.0.0...
ehri-haskell-0.1.0.0: build (lib + exe)
Preprocessing library ehri-haskell-0.1.0.0...
Preprocessing executable 'ehri-haskell-exe' for ehri-haskell-0.1.0.0...
ehri-haskell-0.1.0.0: copy/register
Installing library in
/mnt/docs/RubymineProjects/ehri-haskell/.stack-work/install/x86_64-linux/lts-8.6/8.0.2/lib/x86_64-linux-ghc-8.0.2/ehri-haskell-0.1.0.0-Kh3VLZPfbij7EgcL22QBMN
Installing executable(s) in
/mnt/docs/RubymineProjects/ehri-haskell/.stack-work/install/x86_64-linux/lts-8.6/8.0.2/bin
/mnt/docs/RubymineProjects/ehri-haskell/.stack-work/install/x86_64-linux/lts-8.6/8.0.2/bin/.copyFile5965166491189641421.tmp:
copyFile: does not exist (Host is down)
'cabal copy' failed. Error message:
-- While building package ehri-haskell-0.1.0.0 using:
/root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 copy
Process exited with code: ExitFailure 1
One possible cause of this issue is:
* No module named "Main". The 'main-is' source file should usually have a header indicating that it's a 'Main' module.
# stack --version
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd (4640 commits) x86_64 hpack-0.17.0
Looks like the issue is caused by the depth of the folder where the project lives (Windows 10, x64). From the moment the depth exceeds some threshold, described error appears. So try moving the project folder up in directories tree.
I am trying to debug some compilation problem and I would like to know if it is possible to have non interleaving build steps, like displayed here.
$ stack build
string-conv-0.1: configure
string-conv-0.1: build
dotnet-timespan-0.0.1.0: configure
dotnet-timespan-0.0.1.0: build
servant-0.7: configure
string-conv-0.1: copy/register
dotnet-timespan-0.0.1.0: copy/register
servant-0.7: build
control-monad-omega-0.3.1: configure
control-monad-omega-0.3.1: build
swagger2-2.0.1: configure
control-monad-omega-0.3.1: copy/register
swagger2-2.0.1: build
eventstore-0.12.0.0: configure
eventstore-0.12.0.0: build
servant-0.7: copy/register
servant-client-0.7: configure
servant-client-0.7: build
servant-docs-0.7: configure
servant-docs-0.7: build
servant-client-0.7: copy/register
servant-server-0.7: configure
servant-server-0.7: build
servant-server-0.7: copy/register
servant-docs-0.7: copy/register
swagger2-2.0.1: copy/register
servant-swagger-1.0.3: configure
servant-swagger-1.0.3: build
servant-swagger-1.0.3: copy/register
eventstore-0.12.0.0: copy/register
pl-cqrs-0.1.0.0: configure
pl-cqrs-0.1.0.0: build
pl-cqrs-0.1.0.0: copy/register
pl-server-0.1.0.0: configure
pl-server-0.1.0.0: build
pl-server-0.1.0.0: copy/register
pl-wrapper-0.0.0: configure
pl-wrapper-0.0.0: build
pl-wrapper-0.0.0: copy/register
Completed 13 action(s).
You could override the number of jobs used to compile with
stack build --jobs=1
Without it
$ stack build
hnexus-models-0.1.0.0: configure
hnexus-models-0.1.0.0: build
key-doc-schema-0.1.0.0: configure
key-doc-schema-0.1.0.0: build
key-doc-schema-0.1.0.0: copy/register
key-doc-client-0.1.0.0: configure
hnexus-models-0.1.0.0: copy/register
key-doc-client-0.1.0.0: build
hnexus-mschema-0.1.0.0: configure
hnexus-mschema-0.1.0.0: build
...
with it
$ stack build --jobs=1
hnexus-models-0.1.0.0: configure
hnexus-models-0.1.0.0: build
hnexus-models-0.1.0.0: copy/register
hnexus-mschema-0.1.0.0: configure
hnexus-mschema-0.1.0.0: build
hnexus-mschema-0.1.0.0: copy/register
bnexus-mschema-0.1.0.0: configure
bnexus-mschema-0.1.0.0: build
bnexus-mschema-0.1.0.0: copy/register
bnexus-client-0.1.0.0: configure
bnexus-client-0.1.0.0: build
...
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)
No Haskell Platform
I executed these commands
stack new my-project yesod-sqlite && cd my-project
stack install yesod-bin cabal-install --install-ghc
stack setup
stack build <--- the error occured
In 'stack build' command, the package installations were done. But, when it build the project, the error occured.
Command Prompt
>stack build
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
my-project-0.0.0: build
Preprocessing library my-project-0.0.0...
In-place registering my-project-0.0.0...
Preprocessing executable 'my-project' for my-project-0.0.0...
Linking .stack-work\dist\x86_64-windows\Cabal-1.22.4.0\build\my-project\my-project.exe ...
ghc.exe: could not execute: C:\Users\xxxxx\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.2\lib/../mingw/bin/gcc.exe
-- While building package my-project-0.0.0 using:
C:\Users\xxxxx\AppData\Roaming\local\bin\stack-0.1.5.0\setup-exe-cache\setup-Simple-Cabal-1.22.4.0-x86_64-windows-ghc-7.10.2.exe --builddir=.stack-work\dist\x86_64-windows\Cabal-1.22.4.0\ build lib:my-project exe:my-project --ghc-options -ddump-hi -ddump-to-file
Process exited with code: ExitFailure 1
This is caused by the argument length limit on Windows. Starting in GHC 7.10.3, GHC will support response files for sending linker arguments in order to bypass this limitation. In the meanwhile, a workaround is to manually make the path to your stack root shorter by setting the STACK_ROOT environment variable.
For more information, see https://www.fpcomplete.com/blog/2015/08/stack-ghc-windows