Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stack new requires network to work #3850

vincenthz opened this issue Feb 6, 2018 · 5 comments

stack new requires network to work #3850

vincenthz opened this issue Feb 6, 2018 · 5 comments


Copy link

General summary/comments (optional)

without a network connection, stack new just fails to download a template, even though the template already exists in the template directory.


stack new try to download (update ? refresh cache ?) the template, but fallback to the existing template

 ls ~/.stack/templates/ -lh
total 8.0K
-rw-------. 1 user user 3.8K Feb  5 18:58 new-template.hsfiles
-rw-------. 1 user user   42 Feb  5 18:58 new-template.hsfiles.etag


$ stack new bla
Downloading template "new-template" to create project "bla" in bla/ ...

Warning: Retry number 0 after a total delay of 0 us
Warning: Retry number 3 after a total delay of 300000 us
         If you see this warning and stack fails to download, but running the command again solves the problem, please report here:
HttpExceptionRequest Request {
  host                 = ""
  port                 = 443
  secure               = True
  requestHeaders       = [("If-None-Match","\"20199ac22a46c1b88a1e7e93f6555f4243430c44\"")]
  path                 = "/commercialhaskell/stack-templates/master/new-template.hsfiles"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
 (ConnectionFailure Network.Socket.getAddrInfo: does not exist (Try again))

Stack version

$ stack --version
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0
Copy link

mgsloan commented Feb 10, 2018

👍 Agreed!

Copy link

sudsj commented Feb 15, 2018

Hi, I'm sort of a beginner to Haskell and since this issue was marked newcomer friendly I hope I can contribute. Can you @mgsloan @vincenthz give an overview of what has to be done, it would be helpful.

Copy link

mgsloan commented Feb 16, 2018

@sudsj Hi, sounds good! There are a few ways this could be implemented. I think it would be best to have it do the following:

  • When downloading templates, always store in $STACK_ROOT/templates-cache. Should use Network.HTTP.Download.redownload. Then, load from the stored file.

  • If that function throws RedownloadFailed, then display a message to the user that the download failed and the template might not be up-to-date. Then proceed to load it anyway from the stored file if one exists.

An alternative approach might be to have it clone the templates repo and attempt to do a fetch. This has some nice benefits, but would probably be more complicated. Up to you which approach is taken!

Copy link

Should this issue be closed now that #4173 got merged?

Copy link

That's true, closing. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

5 participants