gobuffalo / buffalo

Rapid Web Development w/ Go
http://gobuffalo.io
MIT License
8.08k stars 577 forks source link

Buffalo Generate Template Naming does not work out of the box #1801

Closed H3rby7 closed 4 years ago

H3rby7 commented 5 years ago

Description

When using buffalo generate resource, the resulting template files use .plush.html, which seems to be desired, but the buffalo App actually looks for them without the .plush.

Steps to Reproduce the Problem

  1. buffalo new kebap
  2. cd kebap
  3. buffalo generate resource kebap price:int
  4. db migrations if wanted.

Example Repository:

https://github.com/H3rby7/kebap

Expected Behavior

All new resource sites are available just fine. E.G. http://localhost:3000/kebaps/ works.

Actual Behavior

Go buffalo errors with 500 - "kebaps/index.html: could not find template kebaps/index.html"

Context

T: %!s(i18n.TranslateFunc=0xabfde0)

app: &{{/kebaps 127.0.0.1:3000 http://127.0.0.1:3000 development  debug {%!s(*logrus.Logger=&{0xc000006018 map[] 0xc0004a9910 false 5 {{0 0} false} {{} 0xc00013f800 8 <nil> 0 <nil>} 0x4e6900})} %!s(http.HandlerFunc=0xa81590) %!s(*sessions.CookieStore=&{[0xc0005d4120] 0xc00050a140}) _kebap_session %!s(*worker.Simple=&{{0xc0002321c0} 0xc000706000 0x58b000 map[] 0xc0004a9930}) %!s(bool=false) [] [] /kebaps/{kebap_id} context.Background.WithCancel.WithCancel %!s(context.CancelFunc=0x58b000)} github.com/gobuffalo/buffalo.*App.defaultErrorMiddleware
github.com/gobuffalo/buffalo.*App.PanicHandler
github.com/gobuffalo/buffalo.RequestLoggerFunc
github.com/gobuffalo/buffalo.sessionSaver
github.com/gobuffalo/mw-forcessl.Middleware.func1
github.com/gobuffalo/mw-paramlogger.ParameterLogger
github.com/gobuffalo/mw-csrf.glob..func1
github.com/gobuffalo/buffalo-pop/pop/popmw.Transaction.func2
github.com/gobuffalo/mw-i18n.*Translator.Middleware.func1 map[%!s(int=404):%!s(buffalo.ErrorHandler=0xa7f580) %!s(int=500):%!s(buffalo.ErrorHandler=0xa7f580)] %!s(*mux.Router=&{0xa8ac50 0xa8ac50 [0xc000280640 0xc000280a00 0xc000280be0 0xc000280dc0 0xc0002810e0 0xc000281400 0xc0002815e0 0xc000281900 0xc000281c20] map[] false [] {false false false {<nil> <nil> []} []  <nil>}}) %!s(*sync.RWMutex=&{{0 0} 0 0 0 0}) [] %!s(*buffalo.App=&{{/ 127.0.0.1:3000 http://127.0.0.1:3000 development  5 {0xc0002321c0} 0xa81590 0xc00051dc80 _kebap_session 0xc00050a1c0 false [] []  0xc00050a100 0x58b000} 0xc00051dca0 map[404:0xa7f580 500:0xa7f580] 0xc000660000 0xc00001acc0 [0xc0005e2100 0xc0005e2280 0xc0005e2480 0xc0005e2300 0xc0005e2380 0xc0005e2500 0xc0005e2580 0xc0005e2400] <nil> [0xc000444600] [/]}) [] []}

authenticity_token: IoBUO/jR+HQamIGCqct0azXlrGAC+rOosCdNhOmWA+jQjdFemzoD9nk56RA31w/QC12lsMYee6csG/MgWJaTYg==

contentType: text/html

current_path: /kebaps/

current_route: {
  "method": "GET",
  "path": "/kebaps/",
  "handler": "github.com/h3rby7/kebap/actions.KebapsResource.List",
  "resourceName": "KebapsResource",
  "pathName": "kebapsPath",
  "aliases": []
}

env: development

languages: [de en-US en en-US]

method: GET

pagination: {"page":1,"per_page":20,"offset":0,"total_entries_size":0,"current_entries_size":0,"total_pages":0}

request_id: 11a905cd623cd8ddf5d8-95caa4c107a47b7fb343

routes: [{
  "method": "GET",
  "path": "/",
  "handler": "github.com/h3rby7/kebap/actions.HomeHandler",
  "pathName": "rootPath",
  "aliases": []
} {
  "method": "GET",
  "path": "/kebaps/",
  "handler": "github.com/h3rby7/kebap/actions.KebapsResource.List",
  "resourceName": "KebapsResource",
  "pathName": "kebapsPath",
  "aliases": []
} {
  "method": "POST",
  "path": "/kebaps/",
  "handler": "github.com/h3rby7/kebap/actions.KebapsResource.Create",
  "resourceName": "KebapsResource",
  "pathName": "kebapsPath",
  "aliases": []
} {
  "method": "GET",
  "path": "/kebaps/new/",
  "handler": "github.com/h3rby7/kebap/actions.KebapsResource.New",
  "resourceName": "KebapsResource",
  "pathName": "newKebapsPath",
  "aliases": []
} {
  "method": "GET",
  "path": "/kebaps/{kebap_id}/",
  "handler": "github.com/h3rby7/kebap/actions.KebapsResource.Show",
  "resourceName": "KebapsResource",
  "pathName": "kebapPath",
  "aliases": []
} {
  "method": "PUT",
  "path": "/kebaps/{kebap_id}/",
  "handler": "github.com/h3rby7/kebap/actions.KebapsResource.Update",
  "resourceName": "KebapsResource",
  "pathName": "kebapPath",
  "aliases": []
} {
  "method": "DELETE",
  "path": "/kebaps/{kebap_id}/",
  "handler": "github.com/h3rby7/kebap/actions.KebapsResource.Destroy",
  "resourceName": "KebapsResource",
  "pathName": "kebapPath",
  "aliases": []
} {
  "method": "GET",
  "path": "/kebaps/{kebap_id}/edit/",
  "handler": "github.com/h3rby7/kebap/actions.KebapsResource.Edit",
  "resourceName": "KebapsResource",
  "pathName": "editKebapPath",
  "aliases": []
}]

t: %!s(func(string, ...interface {}) string=0xac1a90)

tx: postgres://postgres:postgres@127.0.0.1:5432/kebap_development?sslmode=disable

Workaround

Renaming all template files by removing the ".plush" from file names fixes the issue for me.

Info

``` -> Go: Checking installation ✓ The `go` executable was found on your system at: C:\Go\bin\go.exe -> Go: Checking minimum version requirements ✓ Your version of Go, 1.13.1, meets the minimum requirements. -> Go: Checking GOPATH ✓ You are using Go Modules, so no need to worry about the GOPATH. -> Go: Checking Package Management ✓ You are using Go Modules (`go`) for package management. -> Go: Checking PATH ✘ Your PATH (PATH NOT FOUND) does not contain C:\Users\XXXX\go/bin. [[However this IS part of my PATH, I am running on Windows so it is 'C:\Users\XXXX\go\bin' - \ vs /]] Without C:\Users\XXXX\go/bin in your `PATH` any Go executables can not be run globally. For help setting up your Go environment please follow the instructions for you platform at: https://www.gopherguides.com/courses/preparing-your-environment-for-go-development -> Node: Checking installation ✓ The `node` executable was found on your system at: C:\Program Files\nodejs\node.exe -> Node: Checking minimum version requirements ✓ Your version of Node, v12.13.1, meets the minimum requirements. -> NPM: Checking installation ✓ The `npm` executable was found on your system at: C:\Program Files\nodejs\npm.cmd -> NPM: Checking minimum version requirements ✓ Your version of NPM, 6.9.0, meets the minimum requirements. -> Yarn: Checking installation ✓ The `yarnpkg` executable was found on your system at: C:\Users\XXXX\AppData\Roaming\npm\yarnpkg.cmd -> Yarn: Checking minimum version requirements ✓ Your version of Yarn, 1.19.1, meets the minimum requirements. -> PostgreSQL: Checking installation ✘ The `postgres` executable could not be found on your system. For help setting up your Postgres environment please follow the instructions for you platform at: https://www.postgresql.org/download/ -> MySQL: Checking installation ✘ The `mysql` executable could not be found on your system. For help setting up your MySQL environment please follow the instructions for you platform at: https://www.mysql.com/downloads/ -> SQLite3: Checking installation ✘ The `sqlite3` executable could not be found on your system. For help setting up your SQLite3 environment please follow the instructions for you platform at: https://www.sqlite.org/download.html -> Cockroach: Checking installation ✘ The `cockroach` executable could not be found on your system. For help setting up your Cockroach environment please follow the instructions for you platform at: https://www.cockroachlabs.com/docs/stable/ -> Buffalo (CLI): Checking installation ✓ The `buffalo` executable was found on your system at: C:\Users\XXXX\go\bin\buffalo.exe -> Buffalo (CLI): Checking minimum version requirements ✓ Your version of Buffalo (CLI), v0.15.3, meets the minimum requirements. -> Buffalo: Application Details Pwd C:\Users\XXXX\go\src\github.com\h3rby7\kebap Root C:\Users\XXXX\go\src\github.com\h3rby7\kebap GoPath C:\Users\XXXX\go PackagePkg github.com/h3rby7/kebap ActionsPkg github.com/h3rby7/kebap/actions ModelsPkg github.com/h3rby7/kebap/models GriftsPkg github.com/h3rby7/kebap/grifts WithModules true Name kebap Bin bin\kebap VCS git WithPop true WithSQLite false WithDep false WithWebpack true WithNodeJs true WithYarn true WithDocker true WithGrifts true AsWeb true AsAPI false InApp true PackageJSON {map[build:webpack -p --progress dev:webpack --watch]} -> Buffalo: config/buffalo-app.toml name = "kebap" bin = "bin\\kebap" vcs = "git" with_pop = true with_sqlite = false with_dep = false with_webpack = true with_nodejs = true with_yarn = true with_docker = true with_grifts = true as_web = true as_api = false -> Buffalo: config/buffalo-plugins.toml [[plugin]] binary = "buffalo-pop" go_get = "github.com/gobuffalo/buffalo-pop" -> Buffalo: go.mod module github.com/h3rby7/kebap go 1.13 require ( github.com/gobuffalo/buffalo v0.15.3 github.com/gobuffalo/buffalo-pop v1.23.1 github.com/gobuffalo/envy v1.8.1 github.com/gobuffalo/mw-csrf v0.0.0-20190129204204-25460a055517 github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130 github.com/gobuffalo/mw-i18n v0.0.0-20190129204410-552713a3ebb4 github.com/gobuffalo/mw-paramlogger v0.0.0-20190129202837-395da1998525 github.com/gobuffalo/packr/v2 v2.7.1 github.com/gobuffalo/pop v4.12.2+incompatible github.com/gobuffalo/suite v2.8.2+incompatible github.com/gobuffalo/validate v2.0.3+incompatible github.com/gofrs/uuid v3.2.0+incompatible github.com/markbates/grift v1.5.0 github.com/unrolled/secure v0.0.0-20190103195806-76e6d4e9b90c ) ```
paganotoni commented 5 years ago

Tried this one with Buffalo v0.15.0 but could not reproduce it.

H3rby7 commented 4 years ago

Updated initial issue to prevent confusion

H3rby7 commented 4 years ago

Ironically it seems to work for some of the files. My root index.html file works fine

grafik

markbates commented 4 years ago

Your buffalo info output indicates you don’t have a properly setup environment, so you start by addressing those issues.

Also, it would appear you’re using GOPATH. Because of that the problem is mostly due to having a binary at one version and the library code in your GOPATH at a different one, causing these problems.

I recommend turning on GO111MODULE and make sure both your app and binary are at the same versions.

As of today Buffalo no longer supports GOPATH.

I’m closing this ticket, for now, because I believe this is related to mismatch versions in the GOPATH. If you can still replicate the issue with modules enabled and the latest versions of Buffalo, and can provide a reproducible example, I will happily reopen the ticket and help track down the issue with you myself.

H3rby7 commented 4 years ago

Hey @markbates I verified the behaviour running with buffalo 0.15.3 and creating a brand new app, updating the buffalo info and creating a github repo with the code that is generated and not working as desccribed above.

markbates commented 4 years ago

I’ve re-opened. I’m traveling the next week so I won’t be able to give this any attention until I get back.

Hopefully someone else can help before then.

H3rby7 commented 4 years ago

Thank you :)

As mentioned I found a workaround that works for me, so there is no big time pressure on this one.

hekar commented 4 years ago

This seems to be regression. Just encountered this issue on my laptop. Will try updating the golang packages on my desktop to see if I encounter the same problem.

What was the workaround that you found? Did you simply change .plush.html to .html on all the files?

stanislas-m commented 4 years ago

This is a bug in the Auto method. We have a work in progress to solve this issue here: https://github.com/gobuffalo/buffalo-cli/pull/11

paganotoni commented 4 years ago

Closing this one given its a bit old and no more activity has been reported. Please reopen if it still relevant.