smancke / guble

websocket based messaging server written in golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nicer error message when guble is run as unprivileged user

fwilhe opened this issue · comments

When I try to run guble as user on linux (fedora) (built using go get, not in a docker container), I get this message:

$ guble --log-info
2016/01/12 22:35:43 ERROR (github.com/smancke/guble/store.(*SqliteKVStore).Open:124): error db directory not writeable "/var/lib/guble/kv-store.db": "mkdir /var/lib/guble: permission denied"
2016/01/12 22:35:43 error db directory not writeable "/var/lib/guble/kv-store.db": "mkdir /var/lib/guble: permission denied"
! github.com/smancke/guble/store.(*SqliteKVStore).Open:124
! github.com/smancke/guble/gubled.glob.func1:35
! github.com/smancke/guble/gubled.StartupService:108
! github.com/smancke/guble/gubled.Main:97
! main.main:11
! runtime.main:120
! runtime.goexit:1722
2016/01/12 22:35:43 ERROR (github.com/smancke/guble/gubled.Main.func1:86): mkdir /var/lib/guble: permission denied
2016/01/12 22:35:43 mkdir /var/lib/guble: permission denied
! github.com/smancke/guble/gubled.Main.func1:86
! runtime.call32:437
! runtime.gopanic:423
! github.com/smancke/guble/gubled.glob.func1:36
! github.com/smancke/guble/gubled.StartupService:108
! github.com/smancke/guble/gubled.Main:97
! main.main:11
! runtime.main:120
! runtime.goexit:1722

The problem is clear from that message, but I would prefer to catch this case and output a nice message like

guble needs to be run as root because xyz

This would improve the first experience using guble.

Also, this should be mentioned in the readme, I think

Thx, good point!
I'll fix it.

Fixed in master.