plentico / plenti

Static Site Generator with Go backend and Svelte frontend
https://plenti.co
Apache License 2.0
985 stars 50 forks source link

Error when creating a site with theme #210

Closed sapradhan closed 1 year ago

sapradhan commented 1 year ago

I am on plenti v0.5.12, Linux 5.19.2-arch1-1 SMP PREEMPT_DYNAMIC Wed, 17 Aug 2022 13:48:51 +0000 x86_64 GNU/Linux

When I run plenti new site plenti-papermod --theme=https://github.com/plenti-themes/papermod

I get an error segmentation violation code (full error stacktrace below)

I then created a --bare project and try to add two different themes

plenti theme add https://github.com/plenti-themes/papermod 

plenti theme add https://github.com/plenti-themes/bigspring

still get similar error

Stacktrace:

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x23160 pc=0x23160]

runtime stack:
runtime.throw({0x171087c?, 0x7fbc40003450?})
    /opt/hostedtoolcache/go/1.18.5/x64/src/runtime/panic.go:992 +0x71
runtime.sigpanic()
    /opt/hostedtoolcache/go/1.18.5/x64/src/runtime/signal_unix.go:802 +0x389

goroutine 36 [syscall]:
runtime.cgocall(0x95c3a0, 0xc000048598)
    /opt/hostedtoolcache/go/1.18.5/x64/src/runtime/cgocall.go:157 +0x5c fp=0xc000048570 sp=0xc000048538 pc=0x40ffbc
net._C2func_getaddrinfo(0xc0000b6170, 0x0, 0xc000514180, 0xc0000ae028)
    _cgo_gotypes.go:94 +0x56 fp=0xc000048598 sp=0xc000048570 pc=0x614956
net.cgoLookupIPCNAME.func1({0xc0000b6170, 0x0?, 0x0?}, 0xc0000241d0?, 0x61af9b?)
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/cgo_unix.go:160 +0x9f fp=0xc0000485f0 sp=0xc000048598 pc=0x61667f
net.cgoLookupIPCNAME({0x16f5871, 0x3}, {0xc0000241d0, 0xa})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/cgo_unix.go:160 +0x16d fp=0xc000048738 sp=0xc0000485f0 pc=0x615eed
net.cgoIPLookup(0x247da90?, {0x16f5871?, 0xc0000241e0?}, {0xc0000241d0?, 0xc0000e8630?})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/cgo_unix.go:217 +0x3b fp=0xc0000487a8 sp=0xc000048738 pc=0x61673b
net.cgoLookupIP.func1()
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/cgo_unix.go:227 +0x36 fp=0xc0000487e0 sp=0xc0000487a8 pc=0x616b76
runtime.goexit()
    /opt/hostedtoolcache/go/1.18.5/x64/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc0000487e8 sp=0xc0000487e0 pc=0x4703c1
created by net.cgoLookupIP
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/cgo_unix.go:227 +0x12a

goroutine 1 [select]:
net/http.(*Transport).getConn(0x2428820, 0xc000156bc0, {{}, 0x0, {0xc0004f2870, 0x5}, {0xc0000241d0, 0xe}, 0x0})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:1375 +0x5c6
net/http.(*Transport).roundTrip(0x2428820, 0xc00012e100)
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:581 +0x76f
net/http.(*Transport).RoundTrip(0x4199e5?, 0x1e33ec0?)
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/roundtrip.go:17 +0x19
net/http.send(0xc00012e100, {0x1e33ec0, 0x2428820}, {0x16e13c0?, 0x1?, 0x0?})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/client.go:252 +0x5d8
net/http.(*Client).send(0x247e1a0, 0xc00012e100, {0x7fbc65433f68?, 0x2a?, 0x0?})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/client.go:176 +0x9b
net/http.(*Client).do(0x247e1a0, 0xc00012e100)
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/client.go:725 +0x8f5
net/http.(*Client).Do(...)
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/client.go:593
github.com/go-git/go-git/v5/plumbing/transport/http.advertisedReferences(0xc00009b650, {0x16fb136, 0xf})
    /home/runner/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/plumbing/transport/http/common.go:48 +0x1ce
github.com/go-git/go-git/v5/plumbing/transport/http.(*upSession).AdvertisedReferences(0xc0000c8f60?)
    /home/runner/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/plumbing/transport/http/upload_pack.go:28 +0x28
github.com/go-git/go-git/v5.(*Remote).fetch(0xc00000e090, {0x1e38fb0, 0xc0000b6020}, 0xc0000c37e8)
    /home/runner/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/remote.go:319 +0x1dd
github.com/go-git/go-git/v5.(*Repository).fetchAndUpdateReferences(0xc00009b140?, {0x1e38fb0, 0xc0000b6020}, 0xc0000c37e8, {0x16f5c7d, 0x4})
    /home/runner/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/repository.go:976 +0x9a
github.com/go-git/go-git/v5.(*Repository).clone(0xc00009b140, {0x1e38fb0, 0xc0000b6020}, 0xc0000c38f8)
    /home/runner/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/repository.go:843 +0x334
github.com/go-git/go-git/v5.PlainCloneContext({0x1e38fb0, 0xc0000b6020}, {0xc00002c3c0, 0x1f}, 0x8?, 0x2?)
    /home/runner/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/repository.go:417 +0x8c
github.com/go-git/go-git/v5.PlainClone(...)
    /home/runner/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/repository.go:393
github.com/plentico/plenti/cmd.addTheme({0xc00002c3c0?, 0xc0000b7530?}, {0x7ffc225b1ae2?, 0x16f7284?}, {0x0?, 0x7ffc225b1b03?})
    /home/runner/work/plenti/plenti/cmd/theme_add.go:73 +0xa5
github.com/plentico/plenti/cmd.glob..func6(0x242ac60?, {0xc0000d5720?, 0x2?, 0x2?})
    /home/runner/work/plenti/plenti/cmd/site.go:102 +0x970
github.com/spf13/cobra.(*Command).execute(0x242ac60, {0xc0000d56e0, 0x2, 0x2})
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0x242a4e0)
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x39c
github.com/spf13/cobra.(*Command).Execute(...)
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/plentico/plenti/cmd.Execute()
    /home/runner/work/plenti/plenti/cmd/root.go:59 +0x25
main.main()
    /home/runner/work/plenti/plenti/main.go:7 +0x17

goroutine 34 [select]:
net.(*Resolver).lookupIPAddr(0x247da80, {0x1e38fe8?, 0xc0000b1e00}, {0x16f5871, 0x3}, {0xc0000241d0, 0xa})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/lookup.go:325 +0x51b
net.(*Resolver).internetAddrList(0x1e38fe8?, {0x1e38fe8?, 0xc0000b1e00?}, {0x16f5871, 0x3}, {0xc0000241d0?, 0xe?})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/ipsock.go:288 +0x67a
net.(*Resolver).resolveAddrList(0x24d2fe8?, {0x1e38fe8, 0xc0000b1e00}, {0x16f5db9, 0x4}, {0x16f5871?, 0x419d01?}, {0xc0000241d0, 0xe}, {0x0, ...})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/dial.go:221 +0x41b
net.(*Dialer).DialContext(0xc0000b01e0, {0x1e38fb0, 0xc0000b6020}, {0x16f5871, 0x3}, {0xc0000241d0, 0xe})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/dial.go:406 +0x448
net/http.(*Transport).dial(0x7fbc8e0f85b8?, {0x1e38fb0?, 0xc0000b6020?}, {0x16f5871?, 0x0?}, {0xc0000241d0?, 0x0?})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:1169 +0xda
net/http.(*Transport).dialConn(0x2428820, {0x1e38fb0, 0xc0000b6020}, {{}, 0x0, {0xc0004f2870, 0x5}, {0xc0000241d0, 0xe}, 0x0})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:1607 +0x83f
net/http.(*Transport).dialConnFor(0x0?, 0xc0000e8630)
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:1449 +0xb0
created by net/http.(*Transport).queueForDial
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:1418 +0x3d2

goroutine 35 [select]:
net.cgoLookupIP({0x1e38f78, 0xc000156c40}, {0x16f5871, 0x3}, {0xc0000241d0, 0xa})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/cgo_unix.go:228 +0x1aa
net.(*Resolver).lookupIP(0x247da80, {0x1e38f78, 0xc000156c40}, {0x16f5871, 0x3}, {0xc0000241d0, 0xa})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/lookup_unix.go:96 +0x128
net.glob..func1({0x1e38f78?, 0xc000156c40?}, 0x0?, {0x16f5871?, 0x0?}, {0xc0000241d0?, 0x70e370?})
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/hook.go:23 +0x3d
net.(*Resolver).lookupIPAddr.func1()
    /opt/hostedtoolcache/go/1.18.5/x64/src/net/lookup.go:319 +0x9f
internal/singleflight.(*Group).doCall(0x247da90, 0xc000020280, {0xc0000241e0, 0xe}, 0xc0000e8630?)
    /opt/hostedtoolcache/go/1.18.5/x64/src/internal/singleflight/singleflight.go:95 +0x3b
created by internal/singleflight.(*Group).DoChan
    /opt/hostedtoolcache/go/1.18.5/x64/src/internal/singleflight/singleflight.go:88 +0x2ec
jimafisk commented 1 year ago

Hi @sapradhan,

Thanks for the bug report. When I tried the Papermod theme (https://github.com/plenti-themes/papermod) just now I got this error:

Building... 2022/09/05 11:45:29 build.go:154: 
Error in DataSource build step
Could not get all content from project 
Error getting content from content/posts/_blueprint.json 
Unable to read content because: unexpected end of JSON input

I change the Plenti API from time to time and the themes don't always catch up right away. I just pushed a change to fix this particular error (and a couple of others).

However, it seems like you're seeing something different that might be related to go-git. Did you install Plenti by manually downloading the binary from the releases tab?

jimafisk commented 1 year ago

This issue might be related to cgo: https://stackoverflow.com/questions/69773478/golang-fatal-error-unexpected-signal-during-runtime-execution

Statically linking glibc could be causing a bug somewhere with ld, the go compiler, or glibc. I'm curious if there are other Arch users experiencing the same thing? Seems to be fine on Debian distros.

sapradhan commented 1 year ago

@jimafisk greatly appreciate your prompt response.

Did you install Plenti by manually downloading the binary from the releases tab?

I installed it from AUR I just downloaded plenti from releases and ran - same result

This issue might be related to cgo: https://stackoverflow.com/questions/69773478/golang-fatal-error-unexpected-signal-during-runtime-execution

Sorry I dont have much experience with this. I can try to build from source if you can provide instructions

jimafisk commented 1 year ago

Woah I didn't know about https://github.com/hapakaien/aur-packages. Very cool, thanks for building an AUR package for Plenti @hapakaien!

I'll have to install Arch to see if I can replicate this on my machine. @sapradhan is it just the theme commands that are giving you issues? Curious if you're able to do other things like create a new site plenti new site test then cd test and start up the local webserver plenti serve.

If it's just the theme commands giving you trouble, this might be isolated to the go-git dependency. Those commands are really just helpers for downloading themes and managing updates without worrying about git submodules. You can work around this manually if you'd like, just download Papermod directly, unzip it and place it inside a themes folder in your project. Then edit your plenti.json sitewide configuration file and add "theme": "papermod", (assuming your folder structure is themes/papermod). You don't need to add any of the theme_config stuff, that's only used for managing updates and is optional. Does something like that work for now?

sapradhan commented 1 year ago

I can run plenti new and plenti serve without issues on a new site with default content. anything related to theme gets me the above mentioned error.

I installed papermod manually and on plenti serve got similar error that you have posted. I guess this will be fixed in next release .

Error in DataSource build step
Could not get all content from virtual theme
Error getting content from content/posts/_blueprint.json
Unable to read content because: unexpected end of JSON input

I also tried on a Windows machine with Arch on WSL2, same error using theme commands. So it is likely something with Arch

jimafisk commented 1 year ago

That error leads me to believe you have a blank _blueprint.json file in either:

You should be able to simply edit those files and add a blank JSON object {} to them to fix this issue. If you're planning on using the built in CMS, you could add default content here for creating new pages. The papermod theme should be updated already.

I also tried on a Windows machine with Arch on WSL2, same error using theme commands. So it is likely something with Arch

Thanks for testing that out, that's good to know!

sapradhan commented 1 year ago

With this plenti serve executed without errors. However it seems that I ended up with content from the papermod theme but assets/css from default install image

steps I followed were

plenti new site plenti-papermod2
# unzip papermod-main.zip to themes/papermod
# add theme in plenti.json  

plenti.json

{
    "routes": {
        "pages": ":filename",
        "index": ":paginate(totalPages)"
    },
    "baseurl": "/",
    "build": "public",
    "local": {
        "port": 3000
    },
    "cms": {
        "repo": "https://gitlab.com/YourGroup/YourRepo",
        "redirect_url": "http://localhost:3000/admin/",
        "app_id": "",
        "branch": "main"
    },
    "theme": "papermod"
}
jimafisk commented 1 year ago

Ah ok I see. There's a couple of concepts here that can hopefully clear things up:

  1. Any file in the base project will override a matching theme file
  2. By default the base project will inherit layouts, content, and assets from the theme

To fix the first issue, it would be helpful to start from a site with less content and layouts already defined. When you run plenti new site plenti-papermod2 behind the scenes we're using the learner starter which is used for someone who wants to check out Plenti for the first time and view some basic concepts that are already implemented. To start from a blank site just pass the --bare flag like: plenti new site plenti-papermod2 --bare. Even this will have some content that you'll want to manually delete (usually happens automatically with theme commands):

Then just make sure to add the following routes from the theme to your plenti.json file (also would normally happen automatically):

"routes": {
  "pages": ":filename",
  "index": ":paginate(totalPages)"
},

For the second issue, you could use an exclude inside of your theme_config: https://plenti.co/docs/themes. If you do this without handling it in your base project, it will break your site (you'd need a content/index.json at the very least). I don't think you want to do this in your case. It sounds like you want to use the theme as starting point and make customizations. In that case when you want to edit a page, just copy it from the theme to your project and make the edit there (e.g. cp themes/papermod/content/index.json content/.).

jimafisk commented 1 year ago

@sapradhan hopefully you were able to get the theme working on your end, I'm closing this issue out for now. If you still have questions just let me know!