Home
Support Forums

Publish + Swift: Deploy failed

I change my blog title from text to image as below. And get a deploy error. The site is going well in localhost, please have a look.

.a(.class("site-blog"), .href("/"), .img(.src(context.site.imagePath!), .width(400), .height(64))),
1:11:09 AM: Build ready to start
1:11:11 AM: build-image version: 653805ca4a64301556e56dc4b321ef8fc20cbb7c
1:11:11 AM: build-image tag: v3.8.2
1:11:11 AM: buildbot version: 5ca46ad10ed1b3bf6d683d62872e59029498e5a4
1:11:11 AM: Fetching cached dependencies
1:11:11 AM: Starting to download cache of 485.7MB
1:11:13 AM: Finished downloading cache in 2.403131025s
1:11:13 AM: Starting to extract cache
1:11:28 AM: Finished extracting cache in 14.626603449s
1:11:28 AM: Finished fetching cache in 17.155189444s
1:11:28 AM: Starting to prepare the repo for build
1:11:28 AM: Preparing Git Reference refs/heads/master
1:11:30 AM: Parsing package.json dependencies
1:11:30 AM: Starting build script
1:11:30 AM: Installing dependencies
1:11:30 AM: Python version set to 2.7
1:11:31 AM: Started restoring cached node version
1:11:33 AM: Finished restoring cached node version
1:11:34 AM: v12.18.0 is already installed.
1:11:35 AM: Now using node v12.18.0 (npm v6.14.4)
1:11:35 AM: Started restoring cached build plugins
1:11:35 AM: Finished restoring cached build plugins
1:11:35 AM: Attempting ruby version 2.7.1, read from environment
1:11:36 AM: Started restoring cached ruby version
1:11:36 AM: Finished restoring cached ruby version
1:11:38 AM: Using ruby version 2.7.1
1:11:38 AM: Using PHP version 5.6
1:11:38 AM: Started restoring cached Swift version
1:11:40 AM: Finished restoring cached Swift version
1:11:40 AM: 5.2 is already installed.
1:11:40 AM: Using Swift version 5.2
1:11:40 AM: Building Swift Package
1:11:40 AM: Started restoring cached swift build
1:11:40 AM: Finished restoring cached swift build
1:11:45 AM: Updating https://github.com/johnsundell/plot.git
1:11:46 AM: Updating https://github.com/johnsundell/publish.git
1:11:46 AM: Updating https://github.com/johnsundell/splash.git
1:11:46 AM: Updating https://github.com/johnsundell/splashpublishplugin
1:11:47 AM: Updating https://github.com/johnsundell/shellout.git
1:11:47 AM: Updating https://github.com/johnsundell/files.git
1:11:48 AM: Updating https://github.com/johnsundell/codextended.git
1:11:48 AM: Updating https://github.com/johnsundell/ink.git
1:11:49 AM: Updating https://github.com/johnsundell/sweep.git
1:11:57 AM: Everything is already up-to-date
1:11:58 AM: [1/15] Merging module Codextended
1:11:58 AM: [2/15] Merging module Files
1:11:58 AM: [3/15] Merging module Sweep
1:11:58 AM: [4/15] Wrapping AST for Files for debugging
1:11:58 AM: [5/15] Wrapping AST for Codextended for debugging
1:11:58 AM: [6/15] Wrapping AST for Sweep for debugging
1:11:58 AM: [7/15] Merging module ShellOut
1:11:58 AM: [8/15] Wrapping AST for ShellOut for debugging
1:11:58 AM: [9/16] Merging module Splash
1:11:58 AM: [10/17] Wrapping AST for Splash for debugging
1:11:58 AM: [11/17] Merging module Ink
1:11:58 AM: [12/17] Wrapping AST for Ink for debugging
1:11:59 AM: [13/18] Merging module Plot
1:11:59 AM: [14/18] Wrapping AST for Plot for debugging
1:11:59 AM: [15/19] Merging module Publish
1:11:59 AM: [16/20] Wrapping AST for Publish for debugging
1:12:00 AM: [17/20] Merging module SplashPublishPlugin
1:12:00 AM: [18/21] Wrapping AST for SplashPublishPlugin for debugging
1:12:00 AM: [19/22] Compiling MyBlog main.swift
1:12:13 AM: [20/22] Compiling MyBlog Theme+Haibo.swift
1:12:13 AM: /opt/build/repo/Sources/MyBlog/Theme+Haibo.swift:219:90: error: referencing static method 'width' on 'Attribute' requires that 'HTML.ImageContext' conform to 'HTMLDimensionContext'
1:12:13 AM:                 .a(.class("site-blog"), .href("/"), .img(.src(context.site.imagePath!), .width(400), .height(64))),
1:12:13 AM:                                                                                          ^
1:12:13 AM: /opt/build/repo/.build/checkouts/plot/Sources/Plot/API/HTMLAttributes.swift:332:8: note: where 'Context' = 'HTML.ImageContext'
1:12:13 AM: public extension Attribute where Context: HTMLDimensionContext {
1:12:13 AM:        ^
1:12:13 AM: /opt/build/repo/Sources/MyBlog/Theme+Haibo.swift:219:103: error: referencing static method 'height' on 'Attribute' requires that 'HTML.ImageContext' conform to 'HTMLDimensionContext'
1:12:13 AM:                 .a(.class("site-blog"), .href("/"), .img(.src(context.site.imagePath!), .width(400), .height(64))),
1:12:13 AM:                                                                                                       ^
1:12:13 AM: /opt/build/repo/.build/checkouts/plot/Sources/Plot/API/HTMLAttributes.swift:332:8: note: where 'Context' = 'HTML.ImageContext'
1:12:13 AM: public extension Attribute where Context: HTMLDimensionContext {
1:12:13 AM:        ^
1:12:13 AM: Error building Swift package
1:12:13 AM: Build was terminated: Build script returned non-zero exit code: 1
1:12:13 AM: Creating deploy upload records
1:12:13 AM: Failing build: Failed to build site
1:12:13 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
1:12:13 AM: Finished processing build request in 1m2.628662662s

Hey there, @HaiboZhou

Thanks for reaching out! Could you please share your Netlify site name as well as any debugging steps you have already tried?

Hi Hillary,

Sure. My site is www.haibosfashion.com.

And everything is working well locally, I could build my blog project in Xcode and publish it to localhost to test. After that, the new site header image is applied on the webpage correctly. Thus, I think there is something happened when deploying in your hosting.

Here is the changed part of theme file, I only change one line in my original post .a(.class("site-blog"), .href("/"), .img(.src(context.site.imagePath!), .width(400), .height(64))),. Before it is a text element, and now I change it to an image in case it could adopt more devices screen.

private extension Node where Context == HTML.BodyContext {
    static func wrapper(_ nodes: Node...) -> Node {
        .div(.class("wrapper"), .group(nodes))
    }

    static func header<T: Website>(
        for context: PublishingContext<T>,
        selectedSection: T.SectionID?
    ) -> Node {
        let sectionIDs = T.SectionID.allCases

        return .header(
            .wrapper(
                .a(.class("site-blog"), .href("/"), .img(.src(context.site.imagePath!), .width(400), .height(64))),
                .p(.class("site-description"), .text(context.site.description)),
                .if(sectionIDs.count > 1,
                    .nav(
                        .ul(.forEach(sectionIDs) { section in
                            .li(
                                .a(
                                    .class(section == selectedSection ? "selected" : ""),
                                    .href(context.sections[section].path),
                                    .text(context.sections[section].title)
                                )
                            )
                        })
                    )
                )
            )
        )
    }

Hey there!

https://app.netlify.com/sites/haibosfashion/deploys/60fd9f9780c81cc1cc8f85d6#L65

The deploy log reads:

error: referencing static method ‘width’ on ‘Attribute’ requires that ‘HTML.ImageContext’ conform to ‘HTMLDimensionContext’

This indicates a syntax error within the SSG. You may want to take inspiration from our site build debug guide which explains why a site may build locally but not on our systems, and the steps you can take to troubleshoot this.

I would also encourage you to consult with the Publish community regarding the particular error message you’re seeing!

Greeting Man,

Thanks for your reply. I don’t know what you mean SSG, though I’d like to look into your guide.

Because the syntax error is only appearing during deploying in your hosting site. So there is pointless to raise anything to Publish team. We cannot complain the things which are not happened.

Hi @HaiboZhou

The only reference I can find to 'HTMLDimensionContext' or 'HTML.ImageContext' are in @JohnSundell/Plot/Sources/Plot/API/HTML.swift which based on the following line from your deploy log you are using.

Updating https://github.com/johnsundell/plot.git

I don’t see it as a Publish SSG issue, more an issue with Plot. As @Scott suggested, I think reaching out to the author John Sundell about why you might see this issue on Netlify and not locally a wise move. And it is far from complaining, it is enquiring, just as you did here when you opened this thread.