codesoap / mycolog

Keep track of your mushroom cultivation projects
https://codesoap.github.io/mycolog/
MIT License
11 stars 5 forks source link

unable to open database file: no such file or directory #5

Closed norton-chris closed 1 year ago

norton-chris commented 1 year ago

Hi, This seems like a great project and I'd like this to work for me. This is my first time working with go, so maybe I'm making a dumb mistake.

Since I'm on an M1 mac I can't use the amd64 pre-compiled program, so I'm compiling it myself. I followed the instructions on the readme and got a binary file out. However, when I try to execute the binary I get the error:

(base) chris@Chriss-MacBook-Pro bin % ./mycolog 
panic: unable to open database file: no such file or directory

goroutine 1 [running]:
main.init.0()
    /Users/chris/Documents/mycolog/cmd/mycolog/main.go:25 +0x78

Let me know if you need any more information.

Any help would be greatly appreciated. Thanks!

codesoap commented 1 year ago

I have never tried mycolog on a Mac, so I appreciate your feedback very much!

I have tried to reproduce the error and think I've got an idea: mycolog tries to create a new database when it is first started. Assuming that the environment variable XDG_DATA_HOME is not set, mycolog will try to create the database file at $HOME/.local/share/mycolog.sqlite3. I did not consider the case, that the directory $HOME/.local/share doesn't yet exist and suspect that this is the case on your machine. Could you check this and, if it is missing, execute mkdir -p ~/.local/share to create it?

norton-chris commented 1 year ago

That was the issue. Just making that directory fixed it. Thank you!

codesoap commented 1 year ago

Cool, thanks for testing! I'll write up a little change, so that mycolog creates the directory by itself in future versions.

codesoap commented 1 year ago

FYI: The problem should be fixed in https://github.com/codesoap/mycolog/commit/f5b4172ff987ebe00e1fd75ae810df2d337b1f7a