Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Error: you need to be inside your buffalo project path to run this command #629

Closed
neutronstein opened this issue Sep 9, 2017 · 21 comments

Comments

@neutronstein
Copy link

I am getting error below while running buffalo dev and buffalo generate on a fresh buffalo new project.

Error: you need to be inside your buffalo project path to run this command

Buffalo Version

v0.9.4

Go Version

go version go1.9 linux/amd64

@markbates
Copy link
Member

You need to CD into the directory of your application. You are not in the right folder. After you generate your app you need to go into that directory to run your app.

@neutronstein
Copy link
Author

I did since I was able to run buffalo db command.

@markbates
Copy link
Member

Please confirm that you are in the correct directory by running pwd or windows equivalent.

If you still believe you're in the correct directory, please run ls -la or windows equivalent. If you don't see a `.buffalo.dev.yml‘ you're not in the directory.

@neutronstein
Copy link
Author

[neutronstein@infineuty testbuffalo]$ ll -a
total 184
drwxr-xr-x.   7 neutronstein neutronstein   4096  8 sept. 23:57 .
drwxrwxr-x.   3 neutronstein neutronstein   4096  8 sept. 21:39 ..
drwxr-xr-x.   3 neutronstein neutronstein   4096  8 sept. 21:43 assets
-rw-rw-r--.   1 neutronstein neutronstein    358  8 sept. 23:04 database.yml
drwxrwxr-x.   8 neutronstein neutronstein   4096  8 sept. 22:18 .git
drwxr-xr-x.   2 neutronstein neutronstein   4096  8 sept. 22:02 grifts
drwxr-xr-x.   2 neutronstein neutronstein   4096  8 sept. 22:02 models
drwxrwxr-x. 516 neutronstein neutronstein  20480  8 sept. 21:49 node_modules
-rw-rw-r--.   1 neutronstein neutronstein    769  8 sept. 21:49 package.json
-rw-rw-r--.   1 neutronstein neutronstein 133655  8 sept. 21:49 yarn.lock
[neutronstein@infineuty testbuffalo]$ pwd
/home/neutronstein/Projects/Gogland/testbuffalo/src/gitlab.com/neutronstein/testbuffalo
[neutronstein@infineuty testbuffalo]$ echo $GOPATH
/home/neutronstein/Projects/Gogland/testbuffalo
[neutronstein@infineuty testbuffalo]$

@markbates
Copy link
Member

You are missing half of the directories and files. That's why it doesn't think you're in a Buffalo app. Did you, or something delete them? How did you create your app?

@neutronstein
Copy link
Author

I ran buffalo new testbuffalo

@markbates
Copy link
Member

Try generating another app without using the word buffalo in your app name. See if you have better results. I don't know why you only have half an app. Was there an error during generation perhaps? Did it exit successfully?

@neutronstein
Copy link
Author

there were no errors. I got contrats at the end.
ok i will try to create a new project.

@neutronstein
Copy link
Author

I get the same result.

Congratulations! Your application, alobuff, has been successfully built!

You can find your new application at:
/home/neutronstein/Projects/Gogland/alobuff/src/gitlab.com/neutronstein/alobuff

Please read the README.md file in your new application for next steps on running your application.
[neutronstein@infineuty neutronstein]$ cd alobuff/
[neutronstein@infineuty alobuff]$ ll
total 172
drwxr-xr-x.   3 neutronstein neutronstein   4096  9 sept. 00:37 assets
-rw-rw-r--.   1 neutronstein neutronstein    375  9 sept. 00:43 database.yml
drwxr-xr-x.   2 neutronstein neutronstein   4096  9 sept. 00:43 grifts
drwxr-xr-x.   2 neutronstein neutronstein   4096  9 sept. 00:43 models
drwxrwxr-x. 516 neutronstein neutronstein  20480  9 sept. 00:38 node_modules
-rw-rw-r--.   1 neutronstein neutronstein    765  9 sept. 00:38 package.json
-rw-rw-r--.   1 neutronstein neutronstein 133655  9 sept. 00:38 yarn.lock
[neutronstein@infineuty alobuff]$ 

@markbates
Copy link
Member

There's something seriously wrong here. You only have half an app. I don't know how that's even possible.

Can you run buffalo info and paste the results?

@neutronstein
Copy link
Author

[neutronstein@infineuty alobuff]$ buffalo info
Buffalo version v0.9.4

### Buffalo Version
v0.9.4

### Go Version
go version go1.9 linux/amd64

### Go Env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/neutronstein/Projects/Gogland/alobuff"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build346703305=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

### Node Version
v6.9.5

### NPM Version
3.10.10

### Dep Status
dep Not Found

### PostgreSQL Version
PostgreSQL Not Found

### MySQL Version
mysql  Ver 15.1 Distrib 10.2.8-MariaDB, for Linux (x86_64) using readline 5.1

### SQLite Version
3.14.2 2016-09-12 18:50:49 29dbef4b8585f753861a36d6dd102ca634197bd6
[neutronstein@infineuty alobuff]$ 

@markbates markbates reopened this Sep 9, 2017
@markbates
Copy link
Member

Can you paste the full output from buffalo new alobuff? Here is mine:

buffalo new alobuff                                                                           20:51:25
Buffalo version v0.9.4

--> go get -u golang.org/x/tools/cmd/goimports
--> go get -u github.com/golang/dep/cmd/dep
--> go get -u github.com/motemen/gore
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/README.md
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/actions/actions_test.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/actions/app.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/actions/home.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/actions/home_test.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/actions/render.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/.codeclimate.yml
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/.gitignore
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/grifts/init.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/locales/all.en-us.yaml
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/main.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/templates/_flash.html
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/templates/application.html
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/templates/index.html
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/.buffalo.dev.yml
--> goimports -w actions/actions_test.go actions/app.go actions/home.go actions/home_test.go actions/render.go grifts/init.go main.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/assets/images/logo.svg
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/assets/css/application.scss
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/assets/js/application.js
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/.babelrc
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/package.json
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/public/assets/.gitignore
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/webpack.config.js
--> yarn install --no-progress --save
yarn install v0.27.5
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
warning Your current version of Yarn is out of date. The latest version is "1.0.1" while you're on "0.27.5".
Done in 17.08s.
--> goimports -w actions/actions_test.go actions/app.go actions/home.go actions/home_test.go actions/render.go grifts/init.go main.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/models/models.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/models/models_test.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/grifts/db.go
--> go get github.com/markbates/pop/...
--> database.yml
--> goimports -w actions/actions_test.go actions/app.go actions/home.go actions/home_test.go actions/render.go grifts/db.go grifts/init.go main.go models/models.go models/models_test.go
--> goimports -w actions/actions_test.go actions/app.go actions/home.go actions/home_test.go actions/render.go grifts/db.go grifts/init.go main.go models/models.go models/models_test.go
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/Dockerfile
--> /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/.dockerignore
--> goimports -w actions/actions_test.go actions/app.go actions/home.go actions/home_test.go actions/render.go grifts/db.go grifts/init.go main.go models/models.go models/models_test.go
--> goimports -w actions/actions_test.go actions/app.go actions/home.go actions/home_test.go actions/render.go grifts/db.go grifts/init.go main.go models/models.go models/models_test.go
--> go get -t ./...
--> git init
Initialized empty Git repository in /Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff/.git/
--> git add .
--> git commit -m Initial Commit
[master (root-commit) 95afe41] Initial Commit
 28 files changed, 5167 insertions(+)
 create mode 100644 .babelrc
 create mode 100644 .buffalo.dev.yml
 create mode 100644 .codeclimate.yml
 create mode 100644 .dockerignore
 create mode 100644 .gitignore
 create mode 100644 Dockerfile
 create mode 100644 README.md
 create mode 100644 actions/actions_test.go
 create mode 100644 actions/app.go
 create mode 100644 actions/home.go
 create mode 100644 actions/home_test.go
 create mode 100644 actions/render.go
 create mode 100644 assets/css/application.scss
 create mode 100644 assets/images/logo.svg
 create mode 100644 assets/js/application.js
 create mode 100644 database.yml
 create mode 100644 grifts/db.go
 create mode 100644 grifts/init.go
 create mode 100644 locales/all.en-us.yaml
 create mode 100644 main.go
 create mode 100644 models/models.go
 create mode 100644 models/models_test.go
 create mode 100644 package.json
 create mode 100644 templates/_flash.html
 create mode 100644 templates/application.html
 create mode 100644 templates/index.html
 create mode 100644 webpack.config.js
 create mode 100644 yarn.lock
--> goimports -w alobuff/actions/actions_test.go alobuff/actions/app.go alobuff/actions/home.go alobuff/actions/home_test.go alobuff/actions/render.go alobuff/grifts/db.go alobuff/grifts/init.go alobuff/main.go alobuff/models/models.go alobuff/models/models_test.go
Congratulations! Your application, alobuff, has been successfully built!

You can find your new application at:
/Users/markbates/Dropbox/development/gocode/src/gitlab.com/neutronstein/alobuff

Please read the README.md file in your new application for next steps on running your application.

@neutronstein
Copy link
Author

When I ran buffalo new in default GOPATH I was successful. I guess I need to add $GOPATH/bin to the $PATH for custom GOPATH. I will check and confirm.

@markbates
Copy link
Member

Are you running multiple $GOPATHs? If so, that could be the reason why you only have half an app. The other half might be in a different $GOPATH. Considering the pieces of the app you have, I bet that's what went wrong. Can you confirm?

@neutronstein
Copy link
Author

I don't have multiple GOPATH. I mean for each project I am overring the GOPATH so I have only one at any time.
I tried again but it's no good. when I'm in ~/go it works fine but elsewhere(setting GOPATH elsewhere) it doesn't.

@markbates
Copy link
Member

I can confirm that if you use multiple $GOPATHs, or you change your $GOPATH, then this will happen.

Here's what happened. You installed the buffalo source (and generator templates) in $GOPATH-A then you set up $GOPATH-B and switched to a new path.

$GOPATH-B appears to work correctly in that you have a buffalo command. This is because $GOPATH-A/bin is set on your $PATH.

Because Go doesn't all you to, automatically, attach static files to a binary, Buffalo has to look for most of the template files on disk (some are generated in Go, which is why they aren't generated). When it goes to look up where the templates are it goes to $GOPATH/src/github.com/gobuffalo/buffalo/... to fine the templates folder for the generator, loop through them, and write them out to your project.

Normally, this works just fine, however, since those template are all under $GOPATH-A and you are looking at $GOPATH-B it can't find any templates to copy over. Because of that there are no errors, because it did the right thing (it didn't find templates, so it didn't process any templates).

The $GOPATH is a source of much heated debate in the community, partially because these are the sorts of problems that arise all the time.

The solution here is to stick with one $GOPATH, or install Buffalo into the new $GOPATH.

@neutronstein
Copy link
Author

That's right.

@alexMcosta
Copy link

I seem to be experiencing the same issue, however, I did not change my gopath or have multiple gopaths. Or I am missing something.

Go Env

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/alex/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build413436099=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
Go Env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/alex/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build413436099=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

Buffalo new meow

--> /home/alex/go/src/github.com/alexMcosta/meow/assets/images/logo.svg
--> yarn install --no-progress --save
yarn install v1.3.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
info Lockfile not saved, no dependencies.
Done in 0.06s.
--> /home/alex/go/src/github.com/alexMcosta/meow/models/models.go
--> /home/alex/go/src/github.com/alexMcosta/meow/models/models_test.go
--> /home/alex/go/src/github.com/alexMcosta/meow/grifts/db.go
--> go get github.com/markbates/pop/...
--> database.yml
--> goimports -w meow/grifts/db.go meow/models/models.go meow/models/models_test.go
--> go get -u golang.org/x/tools/cmd/goimports
--> go get -u github.com/motemen/gore
--> go get -t ./...
--> goimports -w grifts/db.go models/models.go models/models_test.go
--> git init
Initialized empty Git repository in /home/alex/go/src/github.com/alexMcosta/meow/.git/
--> git add .
--> git commit -m Initial Commit
[master (root-commit) 84ef3a9] Initial Commit
5 files changed, 787 insertions(+)
create mode 100644 assets/images/logo.svg
create mode 100644 database.yml
create mode 100644 grifts/db.go
create mode 100644 models/models.go
create mode 100644 models/models_test.go
Congratulations! Your application, meow, has been successfully built!

You can find your new application at:
/home/alex/go/src/github.com/alexMcosta/meow

Please read the README.md file in your new application for next steps on running your application.

ls -la in meow

total 36
drwxr-xr-x 6 alex alex 4096 Nov 11 20:12 .
drwxrwxr-x 4 alex alex 4096 Nov 11 20:12 ..
drwxr-xr-x 3 alex alex 4096 Nov 11 20:12 assets
-rw-rw-r-- 1 alex alex 366 Nov 11 20:12 database.yml
drwxrwxr-x 8 alex alex 4096 Nov 11 20:14 .git
drwxr-xr-x 2 alex alex 4096 Nov 11 20:12 grifts
drwxr-xr-x 2 alex alex 4096 Nov 11 20:12 models

@markbates
Copy link
Member

markbates commented Nov 12, 2017 via email

markbates added a commit that referenced this issue Jan 26, 2018
use packr to manage templates for generators. hopefully this fixes issues like #629
@fitzboy
Copy link

fitzboy commented Oct 30, 2019

I am not sure if this is helpful to anyone, but I had the same problem and found out that it was because the project I was working on happened to start with the letters "go"... so I was in "/googleSync" (because that is the name of my project, while I also had a "/go" directory too (which was set to my GOPATH from way back when), but since we use grift, it checks to see if you are in a goPath https://github.com/markbates/grift/blob/master/cmd/grifter.go#L55 and that uses https://github.com/gobuffalo/envy/blob/21930fdb6be26d06691c02664cd65edbf06509ea/envy.go#L209 which just does a check of HasPrefix...

so the short of it is: if your project you are in happens to start with the same prefix as your GOPATH variable, then you will get this error

@raphael0io
Copy link

@neutronstein Had the same issue. Solution was, i installed buffalo before i installed go. I uninstalled buffalo and installed it again. Everything is working fine now! :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants