zsh-users / antigen

The plugin manager for zsh.
http://antigen.sharats.me
MIT License
8.01k stars 279 forks source link

`antigen update` not working inside script #687

Open jackcogdill opened 5 years ago

jackcogdill commented 5 years ago

Description

TL;DR, unixorn/autoupdate-antigen.zshplugin does not seem to be working.

Steps to reproduce

Minimal steps to reproduce this behavior:

1 - `antigen bundle unixorn/autoupdate-antigen.zshplugin`

Expected behavior:

Should auto update once a week and produce some output like this:

Updating mafredri/zsh-async@master... Done. Took 0s.
Updating robbyrussell/oh-my-zsh@master... Done. Took 1s.
Updating sindresorhus/pure@master... Done. Took 0s.
Updating zsh-users/zsh-autosuggestions@master... Done. Took 1s.
Updating zsh-users/zsh-syntax-highlighting@master... Done. Took 1s.

Current behavior:

Never outputs anything.

Software version

Configuration

source ~/.antigen/antigen.zsh
antigen use oh-my-zsh

# Plugins
antigen bundle git
antigen bundle sudo
antigen bundle history
antigen bundle extract
antigen bundle debian

antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle unixorn/autoupdate-antigen.zshplugin # Auto updates for antigen

# Theme
antigen bundle mafredri/zsh-async
antigen bundle sindresorhus/pure

antigen apply

More information

I went through the hassle of forking and rewriting the auto update plugin here.

After some debugging, it seems that everything in the plugin should work, except running antigen update or antigen selfupdate finishes instantly with no output.

I ran which antigen inside the script and it produced this output:

antigen () {
        local MATCH MBEGIN MEND
        [[ "$ZSH_EVAL_CONTEXT" =~ "toplevel:*" || "$ZSH_EVAL_CONTEXT" =~ "cmdarg:*" ]] && source "/my/usr/path/.antigen/antigen.zsh" && eval antigen $@
        return 0
}

It appears that [[ "$ZSH_EVAL_CONTEXT" =~ "toplevel:*" || "$ZSH_EVAL_CONTEXT" =~ "cmdarg:*" ]] evaluates to false. My question is, is this intended behavior for scripts? Why can we not use antigen update inside of a plugin?

svenjacobs commented 3 years ago

Hi @jackcogdill,

have you found a solution to this problem? I would also like to call antigen update from a script of mine which executes update functions of several applications like Homebrew, SDKMAN, etc.

The following snippet inside a ZSH shell script doesn't do anything...

source /usr/local/share/antigen/antigen.zsh
antigen update
jackcogdill commented 3 years ago

@svenjacobs I switched to using zplug since it seemed all around better.

Cypher1 commented 5 months ago

I've also found that antigen selfupdate leaves me with antigen version at 2.2.2 (rather than 2.2.3 which has been released for "some time").

Might try zplug