oppiliappan/dijo

dijo not saving data on macOS

Closed this issue · 9 comments

Hi! I really dig your work here. Unfortunately, it doesn't seem like the JSON output is getting generated after running dijo a few times. The folder is created, but there's no JSON file, so the data isn't persisted from one dijo run to the next:

λ cd ~/Library/Application\ Support/rs.nerdypepper.dijo
λ ll
total 0
drwxr-xr-x   2 myuser   64 Jul 21 21:08 .
drwx------+ 58 myuser 1856 Jul 21 21:08 ..

image

  • Any ideas on if I'm doing something wrong?
  • Is there any special reason for writing to Application Support/ over $XDG_CONFIG_HOME if it's configured on macOS?

Robert @rpearce I noticed that when I installed on MacOs with $ cargo install dijo it saves data just fine.

However if I clone this repo, then invoke with $ cargo run data is not saved.

Is this what you see, too?

@StevenBlack Thank you for your quick 👀!

I installed on macOS via $ cargo install dijo

I'm actually also having this problem on Ubuntu, it saved the first day's entries, but has not persisted anything for the next 2 days.

edit: I used cargo install to install it

edit 2: Yesterday (second day) I also added a new habit, and it did not save that habit.

Very strange, dijo should panic if your file permissions are wrong or if the directory is inaccessible. It is also weird that only some users are facing this issue.

@ondreian could you please paste the outputs of the following, after running dijo, adding a habit and quitting with :q:

  • dijo -V
  • ls -al ~/Library/Application\ Support/rs.nerdypepper.dijo (macOS)
  • ls -al ~/.local/share/dijo/ (gnu/linux)
  • echo $HOME (probably not relevant to this issue)

To answer your question regarding default directory @rpearce, dijo always selects Application Support over $XDG_DATA_HOME on macOS, because macOS doesn't follow XDG base dirs spec (usually).

@ondreian could you please paste the outputs of the following, after running dijo, adding a habit and quitting with :q:

  • dijo -V
dijo 0.1.4
  • ls -al ~/.local/share/dijo/ (gnu/linux)
total 16
drwxrwxr-x  2 benjamin benjamin 4096 Jul 20 11:49  ./
drwx------ 37 benjamin benjamin 4096 Jul 20 21:02  ../
-rw-rw-r--  1 benjamin benjamin    2 Jul 22 11:56 'habit_record[auto].json'
-rw-rw-r--  1 benjamin benjamin  241 Jul 22 11:56  habit_record.json

Shouldn't this be ~/.config/<user>? I have enabled=True enabled in my /etc/xdg/user-dirs.conf

  • echo $HOME (probably not relevant to this issue)
/home/benjamin

I did alt + f4 my terminal in totality when I shut down for the day, but when I was scanning the source code before I installed, it looked like it should persist the state anytime the state is changed. I shouldn't have to always manually :q to shutdown?

edit:
after some investigation if I do any sort of operations and then use alt +f4 to shutdown my terminal nothing is persisted, if I manually :q it is.

@ondreian ah, dijo doesn't autosave. You have to quit with :q to to save and quit. A :write command is in the works, to save state, but that would also be manual. At the moment, auto-save as a feature is not being worked on.

Shouldn't this be ~/.config/?

dijo saves data in $XDG_DATA_HOME and will be saving config files (once added) in $XDG_CONFIG_HOME, as per XDG base dirs spec. In the future, you should be able to choose a data dir to save .json records.

Wow -- :q totally was it. I was using ctrl+c. It almost feels like a SIGINT or SIGTERM or whatever should prompt you, but I'm not on that committee :)

On the XDG note, I have all those vars configured on macOS so that programs will use them, and I can version control those if I want. I wonder if there's a way to specify the save directory for dijo... closing, for the original thing has been sorted by me not using :q.

Thank you!!

ah, dijo doesn't autosave. You have to quit with :q to to save and quit. A :write command is in the works, to save state, but that would also be manual. At the moment, auto-save as a feature is not being worked on.

I can move this discussion to a new issue if you like, seems we have figured out the mystery of the lost information. Before I open a new issue, does autosave fit with the goals of this project?

@rpearce: @charles-l has opened a draft to handle the same, I could, for now:

  • warn users to use :quit to save and close
  • replicate the behavior of :quit on receiving SIGINT

@ondreian Now that I think about it, auto save shouldn't be too hard to implement, feel free to request it over at #10 (I will keep it in my list of things to do nevertheless).