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

Buffalo is returning Error: could not find desired block in actions/app.go instead of adding goth-auth lines to app #48

Closed
nicolebroyak opened this issue Dec 22, 2022 · 3 comments · Fixed by #49
Assignees
Labels
s: fixed was fixed or solution offered
Milestone

Comments

@nicolebroyak
Copy link

nicolebroyak commented Dec 22, 2022

Description

Buffalo is returning Error: could not find desired block in actions/app.go instead of adding goth-auth lines to app

Expected Behavior

Adding auth lines to actions/app.go

Actual Behavior

Error: could not find desired block in actions/app.go
Usage:
  buffalo-goth goth-auth [flags]

Flags:
  -d, --dry-run   run the generator without creating files or running commands
  -h, --help      help for goth-auth

could not find desired block in actions/app.go
Usage:
  buffalo generate goth-auth [flags]

Flags:
  -h, --help   help for goth-auth

ERRO[0000] Error: exit status 1

To Reproduce

wget https://github.com/gobuffalo/cli/releases/download/v0.18.12/buffalo_0.18.12_Linux_x86_64.tar.gz\ntar -xvzf buffalo_0.18.12_Linux_x86_64.tar.gz\nsudo mv buffalo /usr/local/bin/buffalo
buffalo new --db-type mysql --ci-provider gitlab-ci project
cd project/
buffalo plugins install github.com/gobuffalo/buffalo-goth
buffalo g  goth-auth google facebook

Additional Context

Details

buffalo info   
-> Go: Checking installation
✓ The `go` executable was found on your system at: /usr/local/go/bin/go

-> Go: Checking minimum version requirements
✓ Your version of Go, 1.19.4, meets the minimum requirements.

-> Go: Checking Package Management
✓ You are using Go Modules (`go`) for package management.

-> Go: Checking PATH
✓ Your PATH contains /home/niko/go/bin.

-> Node: Checking installation
✓ The `node` executable was found on your system at: /usr/local/bin/node

-> Node: Checking minimum version requirements
✓ Your version of Node, v18.12.0, meets the minimum requirements.

-> NPM: Checking installation
✓ The `npm` executable was found on your system at: /usr/local/bin/npm

-> NPM: Checking minimum version requirements
✓ Your version of NPM, 8.19.2, meets the minimum requirements.

-> Yarn: Checking installation
✓ The `yarnpkg` executable was found on your system at: /usr/local/bin/yarnpkg

-> Yarn: Checking minimum version requirements
✓ Your version of Yarn, 3.3.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 was found on your system at: /usr/bin/mysql

-> MySQL: Checking minimum version requirements
✓ Your version of MySQL, 8.0.31, meets the minimum requirements.

-> 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: /usr/local/bin/buffalo

-> Buffalo (CLI): Checking minimum version requirements
✓ Your version of Buffalo (CLI), v0.18.12, meets the minimum requirements.

-> Buffalo: Application Details
Pwd         /home/niko/code/src/gitlab.com/nicolebroyak/project
Root        /home/niko/code/src/gitlab.com/nicolebroyak/project
GoPath      /home/niko/go
PackagePkg  project
ActionsPkg  project/actions
ModelsPkg   project/models
GriftsPkg   project/grifts
WithModules true
Name        project
Bin         bin/project
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 --mode production --progress dev:webpack --watch]}

-> Buffalo: config/buffalo-app.toml
name = "project"
bin = "bin/project"
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-goth"
  go_get = "github.com/gobuffalo/buffalo-goth@latest"

[[plugin]]
  binary = "buffalo-pop"
  go_get = "github.com/gobuffalo/buffalo-pop/v3@latest"

-> Buffalo: go.mod
module project

go 1.18

require (
	github.com/gobuffalo/buffalo v1.0.1
	github.com/gobuffalo/buffalo-pop/v3 v3.0.6
	github.com/gobuffalo/envy v1.10.2
	github.com/gobuffalo/grift v1.5.2
	github.com/gobuffalo/mw-csrf v1.0.1
	github.com/gobuffalo/mw-forcessl v1.0.1
	github.com/gobuffalo/mw-i18n/v2 v2.0.2
	github.com/gobuffalo/mw-paramlogger v1.0.1
	github.com/gobuffalo/pop/v6 v6.1.0
	github.com/gobuffalo/suite/v4 v4.0.3
	github.com/unrolled/secure v1.13.0
)

require (
	github.com/BurntSushi/toml v1.2.1 // indirect
	github.com/Masterminds/semver/v3 v3.1.1 // indirect
	github.com/aymerick/douceur v0.2.0 // indirect
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/dustin/go-humanize v1.0.0 // indirect
	github.com/fatih/color v1.13.0 // indirect
	github.com/fatih/structs v1.1.0 // indirect
	github.com/felixge/httpsnoop v1.0.1 // indirect
	github.com/fsnotify/fsnotify v1.5.4 // indirect
	github.com/go-sql-driver/mysql v1.6.0 // indirect
	github.com/gobuffalo/buffalo-goth v1.4.0 // indirect
	github.com/gobuffalo/events v1.4.3 // indirect
	github.com/gobuffalo/fizz v1.14.4 // indirect
	github.com/gobuffalo/flect v0.3.0 // indirect
	github.com/gobuffalo/genny/v2 v2.1.0 // indirect
	github.com/gobuffalo/github_flavored_markdown v1.1.3 // indirect
	github.com/gobuffalo/helpers v0.6.7 // indirect
	github.com/gobuffalo/httptest v1.5.2 // indirect
	github.com/gobuffalo/logger v1.0.7 // indirect
	github.com/gobuffalo/meta v0.3.3 // indirect
	github.com/gobuffalo/nulls v0.4.2 // indirect
	github.com/gobuffalo/packd v1.0.2 // indirect
	github.com/gobuffalo/plush/v4 v4.1.16 // indirect
	github.com/gobuffalo/refresh v1.13.2 // indirect
	github.com/gobuffalo/tags/v3 v3.1.4 // indirect
	github.com/gobuffalo/validate/v3 v3.3.3 // indirect
	github.com/gofrs/uuid v4.3.1+incompatible // indirect
	github.com/golang/protobuf v1.4.2 // indirect
	github.com/gorilla/css v1.0.0 // indirect
	github.com/gorilla/handlers v1.5.1 // indirect
	github.com/gorilla/mux v1.8.0 // indirect
	github.com/gorilla/securecookie v1.1.1 // indirect
	github.com/gorilla/sessions v1.2.1 // indirect
	github.com/inconshreveable/mousetrap v1.1.0 // indirect
	github.com/jackc/chunkreader/v2 v2.0.1 // indirect
	github.com/jackc/pgconn v1.13.0 // indirect
	github.com/jackc/pgio v1.0.0 // indirect
	github.com/jackc/pgpassfile v1.0.0 // indirect
	github.com/jackc/pgproto3/v2 v2.3.1 // indirect
	github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
	github.com/jackc/pgtype v1.12.0 // indirect
	github.com/jackc/pgx/v4 v4.17.2 // indirect
	github.com/jmoiron/sqlx v1.3.5 // indirect
	github.com/joho/godotenv v1.4.0 // indirect
	github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
	github.com/luna-duclos/instrumentedsql v1.1.3 // indirect
	github.com/markbates/goth v1.75.2 // indirect
	github.com/mattn/go-colorable v0.1.9 // indirect
	github.com/mattn/go-isatty v0.0.14 // indirect
	github.com/mattn/go-sqlite3 v1.14.16 // indirect
	github.com/microcosm-cc/bluemonday v1.0.20 // indirect
	github.com/mitchellh/go-homedir v1.1.0 // indirect
	github.com/monoculum/formam v3.5.5+incompatible // indirect
	github.com/nicksnyder/go-i18n v1.10.1 // indirect
	github.com/pelletier/go-toml v1.2.0 // indirect
	github.com/pkg/errors v0.9.1 // indirect
	github.com/pmezard/go-difflib v1.0.0 // indirect
	github.com/rogpeppe/go-internal v1.9.0 // indirect
	github.com/sergi/go-diff v1.2.0 // indirect
	github.com/sirupsen/logrus v1.9.0 // indirect
	github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d // indirect
	github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e // indirect
	github.com/spf13/cobra v1.6.1 // indirect
	github.com/spf13/pflag v1.0.5 // indirect
	github.com/stretchr/testify v1.8.1 // indirect
	golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
	golang.org/x/mod v0.7.0 // indirect
	golang.org/x/net v0.3.0 // indirect
	golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect
	golang.org/x/sync v0.1.0 // indirect
	golang.org/x/sys v0.3.0 // indirect
	golang.org/x/term v0.3.0 // indirect
	golang.org/x/text v0.5.0 // indirect
	golang.org/x/tools v0.4.0 // indirect
	google.golang.org/appengine v1.6.6 // indirect
	google.golang.org/protobuf v1.25.0 // indirect
	gopkg.in/yaml.v2 v2.4.0 // indirect
	gopkg.in/yaml.v3 v3.0.1 // indirect
)

@nicolebroyak
Copy link
Author

It seems like I have found an answer for my issue.

	appOnce.Do(func() {
		app = buffalo.New(buffalo.Options{
			Env:         ENV,
			SessionName: "_project_session",
		})

		// Automatically redirect to SSL
		app.Use(forceSSL())

		// Log request parameters (filters apply).
		app.Use(paramlogger.ParameterLogger)

		// Protect against CSRF attacks. https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)
		// Remove to disable this.
		app.Use(csrf.New)

		// Wraps each request in a transaction.
		//   c.Value("tx").(*pop.Connection)
		// Remove to disable this.
		app.Use(popmw.Transaction(models.DB))
		// Setup and use translations:
		app.Use(translations())

		app.GET("/", HomeHandler)

		app.ServeFiles("/", http.FS(public.FS())) // serve files from the public directory
	})

	return app
}

Above there is result of buffalo new --db-type mysql --ci-provider gitlab-ci project

But I found that in some my older project app declaration was different:

func App() *buffalo.App {
	if app == nil {
		app = buffalo.New(buffalo.Options{
			Env:         ENV,
			SessionName: "_project_session",
		})

		// Automatically redirect to SSL
		app.Use(forceSSL())

		// Log request parameters (filters apply).
		app.Use(paramlogger.ParameterLogger)

		// Protect against CSRF attacks. https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)
		// Remove to disable this.
		app.Use(csrf.New)

		// Wraps each request in a transaction.
		//   c.Value("tx").(*pop.Connection)
		// Remove to disable this.
		app.Use(popmw.Transaction(models.DB))
		// Setup and use translations:
		app.Use(translations())

		app.GET("/", HomeHandler)

		app.ServeFiles("/", http.FS(public.FS())) // serve files from the public directory
	}

	return app
}

So switching to the old version of app declaration seemed to help with goth-auth (and probably with everything else which I would be generating in the future).

@sio4 sio4 transferred this issue from gobuffalo/genny Jan 6, 2023
@sio4
Copy link
Member

sio4 commented Jan 6, 2023

Hi @nicolebroyak, Thank you for reporting this issue.

Yes, there was a change on the core module and I was not able to update related things for the change. The change is gobuffalo/cli#229, very rarely there is a chance that app initialization runs twice (or more in theory).

I will work on this issue as soon as possible, but I can't promise ETA for now. Meanwhile, as a quick and dirty workaround, you can manually edit the part so you can work with generators from plugins, and also you can switch back to the new Once style once you have done your generations.

@sio4 sio4 self-assigned this Jan 6, 2023
@sio4 sio4 added the s: accepted was accepted or confirmed label Jan 6, 2023
@sio4 sio4 added this to the v1.5.0 milestone Feb 1, 2023
@sio4 sio4 closed this as completed in #49 Feb 3, 2023
sio4 added a commit that referenced this issue Feb 3, 2023
…lock

fixing could not find desired block (fixes #48)
@sio4 sio4 added s: fixed was fixed or solution offered and removed s: accepted was accepted or confirmed labels Feb 3, 2023
@sio4
Copy link
Member

sio4 commented Feb 3, 2023

Hi @nicolebroyak

I think the issue is just fixed in v1.5.0, which was just released with my patch. Please check the latest version and let me know if you still have the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: fixed was fixed or solution offered
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants