zplug / zplug

:hibiscus: A next-generation plugin manager for zsh
MIT License
5.78k stars 231 forks source link

Ctrl+z (suspend) does not work after zplug loaded #322

Closed kota65535 closed 7 years ago

kota65535 commented 7 years ago

Problem Summary

Ctrl+z (suspend) does not work after zplug loaded.

System Information

Linux chajka 3.10.0-514.2.2.el7.x86_64 #1 SMP Tue Dec 6 23:06:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
zsh 5.0.2 (x86_64-redhat-linux-gnu)
2.3.4

Minimal zshrc

source ~/.zplug/init.zsh
zplug load --verbose

If I comment out zplug load, Ctrl+Z becomes working well.

Steps to Reproduce

  1. Start zsh.
  2. Launch vim.
  3. Try to press Ctrl+Z to suspend vim, but it does not suspend. This also happen in emacs.
paulhybryant commented 7 years ago

I ran into this a couple of times as well.

However, if I exit and start a new shell, it will work again. I cannot seem to reproduce it consistently.

kota65535 commented 7 years ago

Hmm, in my environment, it continues to happen even if I restarted zsh...

paulhybryant commented 7 years ago

Yeah in that case that is more troublesome.

babarot commented 7 years ago

However, if I exit and start a new shell, it will work again.

Perhaps you have set the monitor option

paulhybryant commented 7 years ago

Can you elaborate why using the monitor option will cause C-z to stop working? From the zsh documentation of the monitor option I didn't find relevant information.

babarot commented 7 years ago

Because it is an option related to on/off of job control.

paulhybryant commented 7 years ago

Then if c-z stop working, it should be that the monitor option is not set (in your comment above you seem to indicate it stops working because monitor is set)

Thanks for the quick reply.

kota65535 commented 7 years ago

Appending set -o monitor to my .zshrc makes it work fine, thank you.

paulhybryant commented 7 years ago

I found that this is unset in base/core/load.zsh

There is a todo to make it the default.

bluekeyes commented 7 years ago

I suggest this be reopened and considered a bug, as it seems wrong to me that calling zplug load changes options outside of the loaded plugins. If intentional, it would be helpful to document this behavior; I'm in the process of switching to zplug and it took me quite a bit of time to track down why job control was disabled, since the ZSH docs say that monitor is on by default in interactive shells.

paulhybryant commented 7 years ago

What is the downside / concern of turning monitor on by default?

babarot commented 7 years ago

@paulhybryant zplug performs many processing in the background process. Therefore, it is essential to turn off the monitor option.

babarot commented 7 years ago

However I'll manage it, I think. For example, after all the processing is done, turn on the option...

paulhybryant commented 7 years ago

Thank you for the quick reply @b4b4r07 This might be a dump question but from the zsh manual, the monitor option allows job control. How would that affect the background processing of zplug? If monitor is turned on, background processing will be disabled?

babarot commented 7 years ago

If you turn on monitor option and run zplug status, it looks like the following:

$ zplug status
[zplug] Start to get remote status 35 plugins in parallel

[5] 44501
[6] 44503
[7] 44505
[8] 44507
[9] 44509
[10] 44513
[11] 44515
[12] 44518
[13] 44523
[14] 44525
[15] 44529
[16] 44534
[17] 44537
[18] 44539
[19] 44542
[20] 44545
 ⠸  Fetching...           Valodim/zsh-curl-completion
 ✔  Up-to-date            Valodim/zsh-curl-completion
 ⠧  Fetching...           mattn/jvgreph-completions
 ✔  Up-to-date            Valodim/zsh-curl-completion
 ⠇  Fetching...           mattn/jvgrepi-cli2a0b5724eabbdc95ad921cf
 ⠇  Fetching...           zsh-users/zsh-completionseabbdc95ad921cf
 ✔  Up-to-date            b4b4r07/emoji-cli.shy-substring-search
 ✔  Up-to-date            b4b4r07/d66f7c8f32a0b5724eabbdc95ad921cf
 ✔  Up-to-date            b4b4r07/open-link.sh
 ✔  Up-to-date            zsh-users/zsh-history-substring-search
 ✔  Up-to-date            Valodim/zsh-curl-completionn
 ✔  Up-to-date            Valodim/zsh-curl-completionn
 ✔  Up-to-date            Valodim/zsh-curl-completion
 ✔  Up-to-date            mattn/jvgreph-completionsion
 ✘  Local out of date     zsh-users/zsh-completionseabbdc95ad921cf
 ✔  Up-to-date            Valodim/zsh-curl-completionbbdc95ad921cf
 ✔  Up-to-date            mattn/jvgrep7c8f32a0b5724eabbdc95ad921cf=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✘  Local out of date     zsh-users/zsh-completionsstring-searchags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/emoji-clitory-substring-searchags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/d66f7c8f32a0b5724eabbdc95ad921cf=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/open-link.shmpletion"$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            zsh-users/zsh-history-substring-searchags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            fujiwara/nssh-zsh-completion"$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            motemen/ghq-gomitags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            stedolan/jqtaty:tags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            glidenote/hub-zsh-completion"$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/zsh-gomiags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            peco/pecoscore::tags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            reorx/httpstat:tags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            mrowa44/emojify:tags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ➜  Skip local repo       ~/.modulescore::tags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
[6]    44503 done       { __zplug::core::tags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
[5] 45521
[6] 45524
[7] 45527
[8] 45531
[9] 45533
[10] 45539
[11] 45544
[12] 45554
[13] 45558
[14] 45565
[15] 45572
[16] 45575
[17] 45577
[18] 45579
[19] 45581
[20] 45583
 ⠸  Fetching...           monochromegane/the_platinum_searcher
 ⠴  Fetching...           monochromegane/the_platinum_searcher
 ⠦  Fetching...           monochromegane/the_platinum_searcher
 ⠦  Fetching...           tcnksm/ghrzf-bin
 ➜  Skip local repo       ~/.zshnn/fzf-binde-visual
 ⠇  Fetching...           monochromegane/the_platinum_searcher
 ⠇  Fetching...           tcnksm/ghrh-vimode-visual
 ➜  Skip local repo       ~/.zsh7/ssh-keyregax-highlighting
 ⠇  Fetching...           junegunn/fzf-binntax-highlighting
 ✔  Up-to-date            b4b4r07/zsh-vimode-visuallighting
 ⠏  Fetching...           monochromegane/the_platinum_searcher
 ⠙  Fetching...           monochromegane/the_platinum_searcher
 ✘  Local out of date     monochromegane/the_platinum_searcher
 ✘  Local out of date     monochromegane/the_platinum_searcher
 ✔  Up-to-date            tcnksm/ghrzf-binde-visual
 ✘  Local out of date     monochromegane/the_platinum_searcher
 ✔  Up-to-date            tcnksm/ghrzf-binde-visual
 ➜  Skip local repo       ~/.zsh7/zsh-vimode-visuallightingo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            junegunn/fzf-binegax-highlighting"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/zsh-vimode-visuallightingo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/ssh-keyregax-highlightingo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            kouzoh/mercaridtributionrse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            zsh-users/zsh-syntax-highlightingo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            jhawthorn/fzyistributionrse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/enhancdetags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            philovivero/distributionrse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/ultimatector::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/gdate-doctor
 ✘  Local out of date     zplug/zplugug-doctor::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ➜  Skip local repo       ~/zplug-cdore::tags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/zplug-doctor:parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
[8]    45531 done       { __zplug::core::tags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
[5] 46644
[6] 46648
[7] 46650
 ⠴  Fetching...           wg/wrk
 ✔  Up-to-date            wg/wrkoxy/mitmproxy
 ✔  Up-to-date            wg/wrkoxy/mitmproxy
 ✘  Local out of date     mitmproxy/mitmproxy::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
 ✔  Up-to-date            b4b4r07/git-openags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }
[5]    46644 done       { __zplug::core::tags::parse "$repo"; tags=("${reply[@]}") ; if [[ -d  ]]; ; }

[zplug] Elapsed time: 10.4786 sec.
 ==> Run 'zplug update'. These packages are local out of date:
 - zsh-users/zsh-completions
 - monochromegane/the_platinum_searcher
 - zplug/zplug
 - mitmproxy/mitmproxy
paulhybryant commented 7 years ago

Thanks for the clarification.

I cannot seem to reproduce this in my zsh. zplug status still looks normal after setopt monitor or set -o monitor in my interactive zsh Please let me know what information would be useful to find out why there is such a difference.

babarot commented 7 years ago

Hmm..., anyway thanks. I got. Could you tell me you the output of setopt command?

paulhybryant commented 7 years ago

Here it is.

alwaystoend noappendhistory autocd autonamedirs autopushd autoresume nobgnice braceccl nocaseglob cbases cdablevars nocheckjobs noclobber combiningchars completeinword correct extendedglob extendedhistory noflowcontrol globcomplete histallowclobber histexpiredupsfirst histfcntllock histfindnodups histignorealldups histignoredups histignorespace histnostore histreduceblanks histsavenodups histverify nohup incappendhistory interactive interactivecomments longlistjobs markdirs nonomatch nonotify pathdirs promptbang promptsubst pushdignoredups pushdminus pushdsilent pushdtohome rcquotes sharehistory shinstdin zle

babarot commented 7 years ago

I have tried every possible variation of the option but I couldn't reproduce that.

tell me the output of those command:

$ set -o | sed -e 's/^no\(.*\)on$/\1  off/' -e 's/^no\(.*\)off$/\1  on/'
paulhybryant commented 7 years ago

hmm...I think the problem is on my side...

With setopt monitor, the monitor option is still not in the output of setopt and the output of your command still shows monitor off.

Though Ctrl+Z still works...

Not sure what is going on...

paulhybryant commented 7 years ago

I did more experiment.

In my zsh, after setopt nomonitor ctrl+z stopped working after open some file with vi

with setopt monitor, ctrl+z still works. and zplug status still works fine in this case.

Output of the command in your comment: aliases on allexport off alwayslastprompt on alwaystoend on appendcreate off appendhistory off autocd on autocontinue off autolist on automenu on autonamedirs on autoparamkeys on autoparamslash on autopushd on autoremoveslash on autoresume on badpattern on banghist on bareglobqual on bashautolist off bashrematch off beep on bgnice off braceccl on bsdecho off caseglob off casematch on cbases on cdablevars on chasedots off chaselinks off checkjobs off clobber off combiningchars on completealiases off completeinword on continueonerror off correct on correctall off cprecedences off cshjunkiehistory off cshjunkieloops off cshjunkiequotes off cshnullcmd off cshnullglob off debugbeforecmd on dvorak off emacs off equals on errexit off errreturn off evallineno on exec on extendedglob on extendedhistory on flowcontrol off forcefloat off functionargzero on glob on globalexport on globalrcs on globassign off globcomplete on globdots off globstarshort off globsubst off hashcmds on hashdirs on hashexecutablesonly off hashlistall on histallowclobber on histbeep on histexpiredupsfirst on histfcntllock on histfindnodups on histignorealldups on histignoredups on histignorespace on histlexwords off histnofunctions off histnostore on histreduceblanks on histsavebycopy on histsavenodups on histsubstpattern off histverify on hup off ignorebraces off ignoreclosebraces off ignoreeof off incappendhistory on incappendhistorytime off interactive on interactivecomments on ksharrays off kshautoload off kshglob off kshoptionprint off kshtypeset off kshzerosubscript off listambiguous on listbeep on listpacked off listrowsfirst off listtypes on localloops off localoptions off localpatterns off localtraps off login off longlistjobs on magicequalsubst off mailwarning off markdirs on menucomplete off monitor off multibyte on multifuncdef on multios on match on tify on nullglob off numericglobsort off octalzeroes off overstrike off pathdirs on pathscript off pipefail off posixaliases off posixargzero off posixbuiltins off posixcd off posixidentifiers off posixjobs off posixstrings off posixtraps off printeightbit off printexitvalue off privileged off promptbang on promptcr on promptpercent on promptsp on promptsubst on pushdignoredups on pushdminus on pushdsilent on pushdtohome on rcexpandparam off rcquotes on rcs on recexact off rematchpcre off restricted off rmstarsilent off rmstarwait off sharehistory on shfileexpansion off shglob off shinstdin on shnullcmd off shoptionletters off shortloops on shwordsplit off singlecommand off singlelinezle off sourcetrace off sunkeyboardhack off transientrprompt off trapsasync off typesetsilent off unset on verbose off vi off warncreateglobal off xtrace off zle off

modax commented 7 years ago

Hello,

I can confirm @paulhybryant findings. Adding setopt monitor after zplug load fixes the problem and it does not break zplug status.

~/.zshrc:

...
zplug load
setopt monitor

Versions (Debian unstable):

ii  zplug                                           2.4.0-1                      all
ii  zsh                                             5.3.1-1                      amd64
nalabjp commented 7 years ago

I have same problem. And I fix using setopt monitor after zplug load in .zshrc.

I always use tmux on MacOS. In my environment, this problem only occured with tmux. If without tmux or re-run zsh with tmux, this problem did not occur.

My Environment

$ uname -a
Darwin Caprera.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64
$ zsh --version
zsh 5.3.1 (x86_64-apple-darwin16.3.0)
$ zplug --version
2.4.0
$ tmux -V
tmux 2.3
$ set -o | sed -e 's/^no\(.*\)on$/\1  off/' -e 's/^no\(.*\)off$/\1  on/'
aliases               on
allexport             off
alwayslastprompt      on
alwaystoend           on
appendcreate          off
appendhistory         on
autocd                on
autocontinue          off
autolist              on
automenu              on
autonamedirs          off
autoparamkeys         on
autoparamslash        on
autopushd             on
autoremoveslash       on
autoresume            off
badpattern            on
banghist              on
bareglobqual          on
bashautolist          off
bashrematch           off
beep                  on
bgnice                on
braceccl              off
bsdecho               off
caseglob              on
casematch             on
cbases                off
cdablevars            on
chasedots             off
chaselinks            off
checkjobs             on
clobber               on
combiningchars        off
completealiases       off
completeinword        on
continueonerror       off
correct               on
correctall            off
cprecedences          off
cshjunkiehistory      off
cshjunkieloops        off
cshjunkiequotes       off
cshnullcmd            off
cshnullglob           off
debugbeforecmd        on
dvorak                off
emacs                 off
equals                on
errexit               off
errreturn             off
evallineno            on
exec                  on
extendedglob          off
extendedhistory       on
flowcontrol           on
forcefloat            off
functionargzero       on
glob                  on
globalexport          on
globalrcs             on
globassign            off
globcomplete          off
globdots              off
globstarshort         off
globsubst             off
hashcmds              on
hashdirs              on
hashexecutablesonly   off
hashlistall           on
histallowclobber      off
histbeep              on
histexpiredupsfirst   on
histfcntllock         off
histfindnodups        off
histignorealldups     off
histignoredups        on
histignorespace       on
histlexwords          off
histnofunctions       off
histnostore           off
histreduceblanks      off
histsavebycopy        on
histsavenodups        off
histsubstpattern      off
histverify            on
hup                   on
ignorebraces          off
ignoreclosebraces     off
ignoreeof             off
incappendhistory      on
incappendhistorytime  off
interactive           on
interactivecomments   on
ksharrays             off
kshautoload           off
kshglob               off
kshoptionprint        off
kshtypeset            off
kshzerosubscript      off
listambiguous         on
listbeep              on
listpacked            off
listrowsfirst         off
listtypes             on
localloops            off
localoptions          off
localpatterns         off
localtraps            off
login                 on
longlistjobs          on
magicequalsubst       on
mailwarning           off
markdirs              off
menucomplete          off
monitor               off
multibyte             on
multifuncdef          on
multios               on
nomatch               on
notify                on
nullglob              off
numericglobsort       off
octalzeroes           off
overstrike            off
pathdirs              on
pathscript            off
pipefail              off
posixaliases          off
posixargzero          off
posixbuiltins         off
posixcd               off
posixidentifiers      off
posixjobs             off
posixstrings          off
posixtraps            off
printeightbit         on
printexitvalue        off
privileged            off
promptbang            off
promptcr              off
promptpercent         on
promptsp              on
promptsubst           on
pushdignoredups       on
pushdminus            on
pushdsilent           off
pushdtohome           off
rcexpandparam         off
rcquotes              off
rcs                   on
recexact              off
rematchpcre           off
restricted            off
rmstarsilent          off
rmstarwait            off
sharehistory          on
shfileexpansion       off
shglob                off
shinstdin             on
shnullcmd             off
shoptionletters       off
shortloops            on
shwordsplit           off
singlecommand         off
singlelinezle         off
sourcetrace           off
sunkeyboardhack       off
transientrprompt      off
trapsasync            off
typesetsilent         off
unset                 on
verbose               off
vi                    off
warncreateglobal      off
xtrace                off
zle                   off
casimir commented 7 years ago

This is still happening with version 2.4.1. And I have to say this is still painful. Any insight?

babarot commented 7 years ago

Once all the background processes for zplug are done, the monitor option should be set automatically within 30 seconds.

https://github.com/zplug/zplug/blob/master/base/job/polling.zsh

casimir commented 7 years ago

I can't reproduce it after a zplug clear, guess that was some old cache causing this. Sorry for the noise. And thanks for the quick response @b4b4r07.

RobertAudi commented 7 years ago

@b4b4r07 I have had this issue for way way too long and could not solve it. But then I found a "loophole" which rendered virtually any potential fix useless:

The polling code only checks if the lock file exists. That means that if this file is added manually then zplug will disable the monitor option automatically and indefinitely.

Also the clear command doesn't remove the lock file. This means that it is not impossible that an old lock file that was not cleaned up (maybe due to a zplug job that might have been interrupted).

I fixed the problem by manually removing the lock file. After that, everything worked normally out of the box (without the set -o monitor fix or anything similar).

I haven't looked around but a first step to resolve this issue once and for all would be to check the validity of the lock file. Or check if there are any zplug jobs still running. And if the lock file contains a pid, check if that pid exist and points to a zplug job. But I'm pretty sure testing for the existence of the file is not enough.

simonm commented 6 years ago

Removing the lock file $_zplug_lock fixes the issue for subsequent restarts of zsh.

darthbanana13 commented 5 years ago

I am still having this issue and setopt monitor after zplug load does not fix it. I can reproduce it consistently on all my machines.

Here is my .zshrc

I tried zplug clear, removing the lock file but still noting. I have to manually type in the terminal setopt monitor.

Edit: Removing job.lock worked.

drasill commented 5 years ago

Removing the lock file did work for me.

antekone commented 5 years ago

Removing the lock file works. The filename is ~/.zplug/log/job.lock.

masto commented 1 year ago

FWIW, I just ran into this issue on two different machines after using zplug for a couple of days. It seems like there is no stale lock detection, so it's easy to for something to be interrupted or fail and leave the lock file behind. And unless I'm missing something, there's no protection from multiple processes stomping on each other.

It's easy to fix, after you spend time trying to debug it, give up, and go on a web search that eventually leads to this bug.

I wonder if initializing _zplug_lock with a unique name (include pid?) would mitigate this.

garyo commented 2 months ago

Just chiming in -- ended up here after a long search starting with "no job control in this shell" in my MacOS Terminal. Finally remembered I installed zplug a few weeks ago. Removing the lock file fixed it for me. What is the lock file for? Can I rm -f ~/.zplug/log/job.lock in my init file to prevent this in the future?