fragmenta / fragmenta-cms

A user-friendly CMS written in Go (golang)
http://fragmenta.eu
MIT License
586 stars 70 forks source link

I keep getting "You must create your project in $GOPATH/src" #26

Closed thorad closed 6 years ago

thorad commented 8 years ago

No matter what path I use even if it matches both the $GOPATH/src does not work because I get the "You must create your project in $GOPATH/src" error and I can't find a solution to the problem. Here are the paths I have tried ($GOPATH = C:/Gosites)

C:/Gosites C:/Gosites/src C:/Gosites/src/github.com C:/Gosites/src/github.com/app

And all of them give me the same error?

I have tried changing if !strings.HasPrefix(projectPath, path.Join(os.Getenv("GOPATH"), "src")) { to if !strings.HasPrefix(projectPath, filepath.Join(os.Getenv("GOPATH"), "src")) {

But no success? Please advise me on what I can do to solve this.


go version = go version go1.7 windows/amd64

pmcdowell-okta commented 7 years ago

Actually I just got it to work.

I set GOPATH to the directory I was in. Then created a src directory in that, entered that directory and it worked

kalnode commented 7 years ago

To anyone having trouble with this. If you get a message "You must create your project in $GOPATH/src" then first check if your $GOPATH is defined. This is seperate from plain old $PATH. Use "echo $GOPATH". If it comes up blank, then you need to deal with that first before exe'ing fragmenta. To set gopath, use: "export GOPATH=$(go env GOPATH)". Confirm with "echo $GOPATH". Worked for me.

stevenventimiglia commented 7 years ago

Always use the FULL path as well when running a command. Example:

fragmenta new cms /users/username/go/src/github.com/myaccount/fragmenta/

I tried several times to make this work with ~/go/src/github.com/myaccount/fragmenta - and learned my lesson. ;)

rafaelmagalhaes commented 6 years ago

i have tried all of the above im still getting the error, the Path is correct

IGHQ-ST05:src rafael$ echo $GOPATH
/Users/rafael/Documents/go/

help

lucperkins commented 6 years ago

I am also having this same problem. I write a lot of Go and thus have my environment properly set up and I've tried every possible thing I can think of. But still the same error. Hard for me to imagine anyone using this if it's so hard to create a toy project.

azilber commented 6 years ago

export GOPATH=pwd

$ fragmenta new cms pwd/src 15:01:55 Fetching from url: github.com/fragmenta/fragmenta-cms 15:02:15 Creating files at: /home/website/site/src 15:02:15 Removing all at:/home/website/site/src/.git 15:02:15 Initialising new git repo at:/home/website/site/src 15:02:15 Updating import paths to: /home/website/site/src 15:02:15 Generating new config at /home/website/site/src/secrets/fragmenta.json 15:02:15 Error writing config /home/website/site/src/secrets/fragmenta.json open /home/website/site/src/secrets/fragmenta.json: no such file or directory 15:02:15 Error generating config open /home/website/site/src/secrets/fragmenta.json: no such file or directory

Probably related to all this.. src/secrets directory doesn't exist...

I'm using Go 1.9

stevenventimiglia commented 6 years ago

@azilber - What happens if you create that directory? I've stopped attempting to use Fragmenta, for now, but would appreciate a "fix" or solution that would make the initial setup smoother without such an issue.

stevenventimiglia commented 6 years ago

@pmcdowell-okta - Does this mean that we have to restructure or re-init our Go environment for every project using Fragmenta?

azilber commented 6 years ago

Ok, I think I've figured out how to get it working, although, for the life of me, I can't figure out WHY it's setup this way for CMS projects.

You have to make your GOPATH be your local go resource directory. So for my user 'website' it's: /home/website/go ` $ fragmenta new cms /home/website/go/src/crappysite.com 02:43:58 Fetching from url: github.com/fragmenta/fragmenta-cms 02:44:15 Creating files at: /home/website/go/src/crappysite.com 02:44:16 Removing all at:/home/website/go/src/crappysite.com/.git 02:44:16 Initialising new git repo at:/home/website/go/src/crappysite.com 02:44:16 Updating import paths to: crappysite.com 02:44:16 Generating new config at /home/website/go/src/crappysite.com/secrets/fragmenta.json


Congratulations, we've made a new website at crappysite.com if you wish you can edit the database config at secrets/fragmenta.json and sql at db/migrate To get started, run the following commands: cd /home/website/go/src/crappysite.com fragmenta migrate fragmenta

`

I don't understand WHY it forces you to put stuff into the the go/src directory. That has to be a bug.

kennygrant commented 6 years ago

It's set up this way because Go forces you to put go code in the GOPATH or bad things happen (I know this is somewhat odd). I am considering just making this a warning instead and leaving you to it, as I think the go authors long term want to remove that restriction, but it was in place for a reason (various tools like test broke when outside gopath, though go build itself would work). It is working as intended for now, see:

https://github.com/fragmenta/fragmenta/issues/23