Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: ZUI Functions are not added to $fpath when used with Oh My Zsh (OMZ) #4

Open
2 of 3 tasks
duggum opened this issue Dec 18, 2023 · 0 comments · May be fixed by #5
Open
2 of 3 tasks

[bug]: ZUI Functions are not added to $fpath when used with Oh My Zsh (OMZ) #4

duggum opened this issue Dec 18, 2023 · 0 comments · May be fixed by #5
Assignees
Labels
bug 🐞 Inconsistencies or issues which will cause a problem for users or implementors. triage 📑 The issue is awaiting investigation.

Comments

@duggum
Copy link

duggum commented Dec 18, 2023

Environment

Ubuntu 24.04 on Windows 10 WSL using zsh 5.9 with Oh My Zsh plus ZBrowse and ZUI plugins

Reproduction steps

  1. Install ZBrowse to the OMZ custom plugins directory per the ZBrowse installation isntructions for OMZ
  2. Install ZUI to the OMZ custom plugins directory according to the ZUI installation isntructions for OMZ
  3. Add zbrowse and zui to OMZ's plugins array in .zshrc
  4. Reload the shell or run omz reload
  5. Press crtl+b to launch ZBrowse

Note: I tested this with AND without other OMZ plugins being loaded and the behaviour was the same.

Expected behavior

  1. pressing ctrl+b will launch ZBrowse

Current behavior

Pressing ctrl+b to launch ZBrowse results in the following error:

zbrowse:482: zui-event-loop: function definition file not found

Code snippet

From .zshrc

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
    zui
    zbrowse
)

Additional information

First of all, I realize this may very well be an issue with Oh My Zsh. If that is the case, please let me know and I will go there for resolution. I am not a zsh expert and my experience is limited to using it as my shell with OMZ.

Workaround:

A workaround for this issue is to load ZUI directly, per the Standalone installation instuctions. Placing

source {where-zui-is}/zui.plugin.zsh

in my .zshrc file yields a successful result.

Details:

When loading ZUI as a plugin via OMZ, ZUI's functions directory ($ZUI_REPO_DIR/functions) is not added to the fpath array.
The failure appears to happen due to the following code block (zui.plugin.zsh lines 26-31):

# Update FPATH if:
# 1. Not loading with ZI
# 2. Not having fpath already updated (that would equal: using other plugin manager)
if [[ -z "$ZI_CUR_PLUGIN" && "${fpath[(r)$ZUI_REPO_DIR]}" != $ZUI_REPO_DIR ]]; then
    fpath+=( "$ZUI_REPO_DIR/functions" )
fi

It appears that OMZ is adding $ZUI_REPO_DIR to fpath before it actually loads the plugin. This subsequently causes test no. 2,

"${fpath[(r)$ZUI_REPO_DIR]}" != $ZUI_REPO_DIR`

to fail, and $ZUI_REPO_DIR/functions does not get added to fpath.

This theory is borne out by the fact that bypassing OMZ's plugin loading, by sourcing ZUI directly in .zshrc, solves the problem.

Resolution:

It seems that OMZ automatically adds each plugin directory to fpath before the plugin is actually loaded. This, of
course, clashes with ZUI's method of determining if its function path should be added to fpath for non-ZI plugin managers.

I notice that ZBrowse does not use the same method to test if its functions directory should be added to fpath. Perhaps ZUI could be modified to use the same method, or include a check specifically based on the way Oh My Zsh's deals with plugin directories being added to fpath.

FYI:

The Code of Conduct link is dead

Self-service

  • I'd be willing to address this documentation request myself.

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

No response

@duggum duggum added bug 🐞 Inconsistencies or issues which will cause a problem for users or implementors. triage 📑 The issue is awaiting investigation. labels Dec 18, 2023
ss-o added a commit that referenced this issue Dec 19, 2023
… and zui.plugin.zsh

Breaking change:

Enable ZUI demos only if ZUI[DEMOS] is set, i.e.: typeset -A ZUI; ZUI[DEMOS]=1

This change updates variable and function names in the files stdlib.lzui, utillib.lzui, and zui.plugin.zsh. The updates include changing the names from using underscores to using hyphens, following a more consistent naming convention throughout the codebase.

By updating the names, the codebase becomes more readable and adheres to best practices. This change also improves maintainability, as the code is now more self-explanatory. There are no significant consequences or considerations resulting from this change.

Resolves: #4
Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
@ss-o ss-o linked a pull request Dec 19, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Inconsistencies or issues which will cause a problem for users or implementors. triage 📑 The issue is awaiting investigation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants