fragmenta / fragmenta-cms

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

Problem with initial configuration #7

Closed aliabadi closed 8 years ago

aliabadi commented 8 years ago

Hi,

I am trying to get the CMS up and running on a fresh gentoo linode. I installed Postgre & imported the database configuration from db/migrate. I've also tried this in debian & darwin...same result.

It could be that I am somewhat new to go-lang, but I spent a few good hours looking for what's going wrong yesterday to no avail.

I followed the instructions for installing fragmenta from fragmenta.eu, but I am stuck; getting the following message when I execute 'fragmenta' from the directory where I was expecting my cms files to be:

Fragmenta version: 1.3.1
------
18:49:20 Building server...
18:49:20 Running go fmt at ./...
18:49:21 Building server at /home/manhattan/frag/bin/fragmenta-server-local
18:49:21 CMD go build -o /home/manhattan/frag/bin/fragmenta-server-local server.go
server.go:8:2: import "/home/manhattan/frag/src/app": cannot import absolute path
18:49:21 Error running build exit status 1
18:49:21 Error building server: exit status 1
kennygrant commented 8 years ago

Hi, GOPATH is intended to be the place where all your go projects live, it takes a little getting used to, but it would be worth looking at this article for ref:

https://golang.org/doc/code.html

GOPATH should contain -

bin for binaries pkg for build artefacts src for source code (which can be many projects, and is arranged be repo url).

So, your GOPATH should probably be /home/manhattan/work/ or /home/manhattan/go or something lilke that, and should be set in your .profile file or similar (see instructions above).

Then to make a site, cd to that directory, and use fragmenta new cms github.com/manhattan/mysitename

or something like that (as long as it is in GOPATH src, it doesn't matter so much what the path is). Now within that project dir you'll then find a bin (for server binaries, src for src etc), and your import paths should be of the form "github.com/manhattan/mysitename/src/users" and "github.com/manhattan/mysitename/src/lib/authorise" (so relative to GOPATH). If that is breaking for you though, let me know the command you used to create a new site. It does attempt to take into account GOPATH and expects your sites to be within GOPATH/src, so if they are not it might break. I suspect that is what happened here?

I do need to make this friendlier and issue a warning, a certain amount of Go setup is assumed at the minute, which is probably a bad assumption. At some point I'll be supplying one binary instead, so that you can just run the CMS without bothering with a go install, but I'm not quite at that point yet, and you might want to tinker anyway.

aliabadi commented 8 years ago

Well, I realized part of what was going wrong last nite; I did get the cms to work, but only in development mode.

/home/manhattan is actually where I set my GOPATH (it's a dedicated workspace/project user).

To run the cms the command would actually be fragmenta-cms it seems. It seems to run fine if FRAG_ENV is not set....but now when I try to set FRAG_ENV=production it doesn't want to load.

Here's pretty much what I did to get it working in development mode:

go get github.com/fragmenta
export PATH=$PATH:~/bin
export GOPATH=/home/manhattan
fragmenta new cms frag
cd frag
fragmenta migrate
fragmenta-cms

If I run fragmenta test it gives the same cannot import absolute path error, but from all the source files when it tries to run the tests.

I also just tried running the above site creation process (just changing the psql user's password instead of migrate) from ~/src/ but the same thing happens.

I'm sure I can now search the code and find where the FRAG_ENV modifies things & tinker with it from here, but any insights are appreciated. =]

Thanks!

kennygrant commented 8 years ago

I think the issue is that you've made your frag dir in /home/manhattan/frag - with Go setup you should have ended up with:

/home/manhattan/bin /home/manhattan/pkg /home/manhattan/src

then your project should be at something like this (assuming you want to use the 'frag' dir to put it in):

/home/manhattan/src/frag

which will in turn contain a bin,log,public,src etc for the app itself.

I really need to explain this better in the docs, but assumed people would have set up go fully and have a gopath functioning first. So try setting up your go path as above (with bin/src/pkg dirs), and create a new cms inside /home/manhattan/src/frag, and it should work.