[SOLVED] Stack new and stack init failing ... missing AWS asset "NoSuchBucket"?

Hey there, big fan of Stack and trying to learn Haskell. I tried to start a new project but I’m getting an error when trying to stack new the project and then stack init the partially created project.

chapman@chapman-Alienware-Aurora-Ryzen-Edition:~/code/haskellz$ stack new update-linux-torrents
Downloading template new-template to create project update-linux-torrents in directory update-linux-torrents/...
Downloaded /home/chapman/.stack/templates/new-template.hsfiles.               

Note: The following parameters were needed by the template but not provided: author-email, author-name, category, copyright and github-username.
      
      You can provide them in Stack's global YAML configuration file (/home/chapman/.stack/config.yaml) like this:
      
      templates:
        params:
          author-email: value
          author-name: value
          category: value
          copyright: value
          github-username: value
      
      Or you can pass each one on the command line as parameters like this:
      
      stack new update-linux-torrents new-template -p "author-email:value" -p "author-name:value" -p "category:value" -p "copyright:value" -p "github-username:value"
      
Looking for Cabal or package.yaml files to use to initialise Stack's project-level YAML configuration file.

Using the Cabal packages:
* update-linux-torrents/


Error: [S-8332]
       Stack failed to create project-level YAML configuration, as it was unable to download the index of available snapshots.
       
       This sometimes happens because Certificate Authorities are missing on your system. You can try the Stack command again or manually create the configuration file.
       For help about the content of Stack's YAML configuration files, see (for the most recent release of Stack)
       http://docs.haskellstack.org/en/stable/yaml_configuration/.
       
       While downloading the snapshot index, Stack encountered the following error:
       
       HttpExceptionRequest Request {
         host                 = "s3.amazonaws.com"
         port                 = 443
         secure               = True
         requestHeaders       = [("Accept","application/json"),("User-Agent","The Haskell Stack")]
         path                 = "/haddock.stackage.org/snapshots.json"
         queryString          = ""
         method               = "GET"
         proxy                = Nothing
         rawBody              = False
         redirectCount        = 10
         responseTimeout      = ResponseTimeoutDefault
         requestVersion       = HTTP/1.1
         proxySecureMode      = ProxySecureWithConnect
       }
        (StatusCodeException (Response {responseStatus = Status {statusCode = 404, statusMessage = "Not Found"}, responseVersion = HTTP/1.1, responseHeaders = [("x-amz-request-id","PD74BNR81XHKWAPT"),("x-amz-id-2","MeoI9F/EtS8sk8UJSkTqZFWjo2k/ul0hChSdze7rHmadSYwwNTE1Trya5d7K5HPC6YinO7IzjBQ="),("Content-Type","application/xml"),("Transfer-Encoding","chunked"),("Date","Fri, 05 Jul 2024 19:54:36 GMT"),("Server","AmazonS3")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose, responseOriginalRequest = Request {
         host                 = "s3.amazonaws.com"
         port                 = 443
         secure               = True
         requestHeaders       = [("Accept","application/json"),("User-Agent","The Haskell Stack")]
         path                 = "/haddock.stackage.org/snapshots.json"
         queryString          = ""
         method               = "GET"
         proxy                = Nothing
         rawBody              = False
         redirectCount        = 10
         responseTimeout      = ResponseTimeoutDefault
         requestVersion       = HTTP/1.1
         proxySecureMode      = ProxySecureWithConnect
       }
       }) "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message><BucketName>haddock.stackage.org</BucketName><RequestId>PD74BNR81XHKWAPT</RequestId><HostId>MeoI9F/EtS8sk8UJSkTqZFWjo2k/ul0hChSdze7rHmadSYwwNTE1Trya5d7K5HPC6YinO7IzjBQ=</HostId></Error>")
1 Like

Looks like your global configuration may be out of date, according to the note at: Configuration (project and global) - The Haskell Tool Stack

urls:
  latest-snapshot: https://stackage-haddock.haskell.org/snapshots.json

The default for Stack 1.3.0 to 2.15.3 was https://s3.amazonaws.com/haddock.stackage.org/snapshots.json. Following the handover of the Stackage project to the Haskell Foundation in early 2024, the file at that URL may not be up to date. Users of those versions of Stack should configure the URL to be the default above.

2 Likes

I added that urls bit to ~/.stack/config.yaml and it seemed to make stack init happy again!

chapman@chapman-Alienware-Aurora-Ryzen-Edition:~/code/haskellz/update-linux-torrents$ cat ~/.stack/config.yaml 
# This file contains default non-project-specific settings for Stack, used
# in all projects. For more information about Stack's configuration, see
# http://docs.haskellstack.org/en/stable/yaml_configuration/

# The following parameters are used by 'stack new' to automatically fill fields
# in the Cabal file. We recommend uncommenting them and filling them out if
# you intend to use 'stack new'.
# See https://docs.haskellstack.org/en/stable/yaml_configuration/#templates
templates:
  params:
#    author-name:
#    author-email:
#    copyright:
#    github-username:

# The following parameter specifies Stack's output styles; STYLES is a
# colon-delimited sequence of key=value, where 'key' is a style name and
# 'value' is a semicolon-delimited list of 'ANSI' SGR (Select Graphic
# Rendition) control codes (in decimal). Use 'stack ls stack-colors --basic'
# to see the current sequence.
# stack-colors: STYLES

urls:
  latest-snapshot: https://stackage-haddock.haskell.org/snapshots.json
2 Likes

Glad to hear it. You could also consider updating your stack to the latest version - I don’t know if anything else important has been released recently (I use cabal these days).

1 Like

If you installed stack directly from haskellstack.org, you might want to consider uninstalling and using GHCup since that is the most recent and best supported way of managing your Haskell compilers and build tools. :+1:

Related discussion: [ANN] Stack 2.15.3 and earlier's default source for list of Stackage snapshots not up to date (2024-03)

I would add one thing to @Vix’s advice: if you decide to use GHCup to manage versions of Stack in addition to managing other tools, be aware that you can no longer use Stack command stack upgrade to upgrade Stack. There is a warning here: upgrade command - The Haskell Tool Stack.

That warning is because GHCup uses a small executable on the PATH named stack to use Stack. stack upgrade will assume that executable is Stack and overwrite it with an upgraded Stack executable.

1 Like