mattmc3 / antidote

https://getantidote.github.io - the cure to slow zsh plugin management
MIT License
837 stars 21 forks source link

Does it make sense to move ~/.antidote to $XDG_CACHE_HOME/antidote ? #129

Closed eggbean closed 1 year ago

eggbean commented 1 year ago

I'm quite a new user to antidote, so I am not sure if it makes sense to move ~/.antidote to $XDG_CACHE_HOME/antidote. It's not a directory that needs to be easily accessible by the user, is it?

I don't want to move it to $ZDOTDIR as I haven't set it.

mattmc3 commented 1 year ago

I leave my $ANTIDOTE_HOME in $XDG_CACHE_HOME, and also let antidote manage itself there too. My recommendation is let antidote manage itself and repos in the default cache location, and store your custom plugins in $ZDOTDIR, but let antidote load them.

eggbean commented 1 year ago

...and also let antidote manage itself there too. My recommendation is let antidote manage itself and repos in the default cache location...

Thanks. Do I have to do anything in particular to have antidote manage itself? I'm not sure what you mean by that.

mattmc3 commented 1 year ago

I just mean using antidote update for self updates.

eggbean commented 1 year ago

I have a script which installs and updates everything that needs installing or updating and I have this included in it:

# Setup/update antidote
if [[ $ZSH_VERSION ]]; then
  if [[ ! -d ~/.cache/antidote ]]; then
    git clone --depth=1 https://github.com/mattmc3/antidote.git \
      ~/.cache/antidote
  fi
  source ~/.cache/antidote/antidote.zsh
  antidote load ~/.dotfiles/config/.includes/zsh_plugins.txt
  antidote update
fi

This is in my .zshrc:

# Load antidote
if [[ -d ~/.cache/antidote ]]; then
  source ~/.cache/antidote/antidote.zsh
  antidote load ~/.dotfiles/config/.includes/zsh_plugins.txt
fi

This has been working fine, but I deleted ~/.cache/antidote to see what would happen on a new host and I get these errors when I run the update script:

/home/jason/.dotfiles/config/.includes/zsh_plugins.zsh:source:2: no such file or directory: /home/jason/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-Tarrasch-SLASH-zsh-bd/bd.plugin.zsh
/home/jason/.dotfiles/config/.includes/zsh_plugins.zsh:source:4: no such file or directory: /home/jason/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-jirutka-SLASH-zsh-shift-select/zsh-shift-select.plugin.zsh
/home/jason/.dotfiles/config/.includes/zsh_plugins.zsh:source:6: no such file or directory: /home/jason/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions/zsh-completions.plugin.zsh
/home/jason/.dotfiles/config/.includes/zsh_plugins.zsh:source:8: no such file or directory: /home/jason/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
/home/jason/.dotfiles/config/.includes/zsh_plugins.zsh:source:10: no such file or directory: /home/jason/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh

Why aren't the plugins being reinstalled? Thanks.

mattmc3 commented 1 year ago

This has been working fine, but I deleted ~/.cache/antidote to see what would happen on a new host and I get these errors when I run the update script

By deleting the repos directory, you only invalidated part of the cache. To get antidote to rebuild, you should remove the static file: rm ~/.dotfiles/config/.includes/zsh_plugins.zsh.

As an aside, I also don't recommend checking the static cache file to your dotfiles repo. In my dotfiles, I have it in my .gitignore. If you change machines, your $ZDOTDIR or $HOME directories could be different, meaning the static cache isn't portable across machines - just let antidote regenerate it.

I'm going to re-open this issue because I can see where this behavior wouldn't be intuitive, and I can make antidote load consider the cache invalid if it can't find $ANTIDOTE_HOME due to someone removing it.

eggbean commented 1 year ago

Oh, of course. I forgot about that. Yes, I already have zsh_plugins.zsh git ignored (as it was generated).

mattmc3 commented 1 year ago

The new 1.8.7 release should handle this edge case now.