zdharma-continuum / zinit

🌻 Flexible and fast ZSH plugin manager
MIT License
3.12k stars 129 forks source link

MANPATH doesn't have ~/.zinit/polaris/man, also ~/.zinit/polaris/man doesn't exist #8

Closed ryaminal closed 3 years ago

ryaminal commented 3 years ago

Describe the bug ZPFX=~/.zinit/polaris MANPATH doesn't have $ZPFX/man, also $ZPFX/man doesn't exist.

To Reproduce

# requires the zdharma-continuum/z-a-bin-gem-node annex
# i'm also using ryaminal/z-a-meta-plugins to bring in the annexes(including the one above), but I don't anticipate this being a problem.
zinit wait'0b' lucid for \
  id-as'github-cli' from"gh-r" sbin'usr/bin/gh' atclone'ln -sf $PWD/usr/share/man/man1/* $ZPFX/man/man1' atpull'%atclone' cli/cli \
  ;

Expected behavior Used to be that a $ZPFX/man directory was created and added to the MANPATH directory, this is the expected behavior.

Additional context Mostly I'm just curious if anyone is familiar with why this wouldn't work? Are others seeing this directory existing and an entry in MANPATH? I've tried to look through the code but nothing is indicating the problem.

ryaminal commented 3 years ago
#!/usr/bin/env bash
### zinit ###
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
    print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
    command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
    if command git clone https://github.com/zdharma-continuum/zinit.git "$HOME/.zinit/bin"; then
        print -P "%F{33}â–“â–’â–‘ %F{34}Installation successful.%f%b"
    else
        print -P "%F{160}â–“â–’â–‘ The clone has failed.%f%b"
    fi
    # shellcheck disable=1094
    source "$HOME/.zinit/bin/zinit.zsh"
    zinit self-update
    zinit module build
else
  module_path+=("$HOME/.zinit/bin/zmodules/Src"); zmodload zdharma/zplugin
fi

# shellcheck disable=1094
source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
# shellcheck disable=2154,2034
(( ${+_comps} )) && _comps[zinit]=_zinit

# see https://github.com/zdharma-continuum/zinit#order-of-execution for the following order of mods
# atinit -> atpull! -> make'!!' -> mv -> cp -> make! -> atclone/atpull -> make -> (plugin script loading) -> src -> multisrc -> atload

# Load a few important annexes, without Turbo
# (this is currently required for annexes)
# the annexes, console-tools, and fuzzy are all meta-plugins. they install loads of stuff
zinit light-mode for \
  ryaminal/z-a-meta-plugins \
  annexes \
  ;

zinit wait'0a' lucid for \
  console-tools \
  molovo \
  OMZL::clipboard.zsh \
  OMZL::functions.zsh \
  OMZL::misc.zsh \
  OMZL::termsupport.zsh \
  skywind3000/z.lua \
  chitoku-k/fzf-zsh-completions \
  blockf clarketm/zsh-completions \
  MichaelAquilina/zsh-you-should-use \
  pick'autopair.zsh' hlissner/zsh-autopair \
  '@asdf-vm/asdf' \
  ;

# TODO: add gitmux
# TODO: move alacritty from /usr/bin to polaris or something. requires modifying the .info file, i think.
# the id-as"*_checkout" lines are because those plugins are installed elsewhere("gh-r" or the fuzzy metaplugin or ...), but only the binary. so, we have to check out the repo for the completions and man pages
zinit wait'0b' lucid for \
  OMZL::history.zsh \
  OMZL::key-bindings.zsh \
  from"gh-r" sbin'dasel_linux_amd64 -> dasel' TomWright/dasel \
  from"gh-r" sbin"**/delta" dandavison/delta \
  from"gh-r" sbin'jq-linux64 -> jq' stedolan/jq \
  from"gh-r" sbin'lazygit' jesseduffield/lazygit \
  from"gh-r" sbin'rust-analyzer* -> rust-analyzer' rust-analyzer/rust-analyzer \
  from"gh-r" sbin'selene' Kampfkarren/selene \
  from"gh-r" sbin'neuron' srid/neuron \
  from"gh-r" sbin'glow' bpick"*linux_x86_64.tar.gz" charmbracelet/glow \
  from'gh-r' sbin'**/shellcheck' 'koalaman/shellcheck' \
  from'gh-r' sbin'shfmt_* -> shfmt' '@mvdan/sh' \
  from"gh-r" sbin'starship' starship/starship \
  from"gh-r" sbin'stylua' JohnnyMorganz/StyLua \
  sbin"bin/git-fuzzy" bigH/git-fuzzy \
  sbin"direnv" make'!' atclone'./direnv hook zsh > zhook.zsh' atpull'%atclone' src"zhook.zsh" direnv/direnv \
  from"gh-r" cloneonly nocompletions bpick"*linux64.tar.gz" atclone"rm /usr/bin/nvim; sudo cp -a nvim-linux64/* /usr" atpull'%atclone' ver"nightly" neovim/neovim \
  sbin"target/release/alacritty" atclone"cargo build --release;
    sudo tic -xe alacritty,alacritty-direct extra/alacritty.info;
    sudo cp extra/logo/alacritty-term.svg /usr/share/pixmaps/Alacritty.svg;
    sudo desktop-file-install extra/linux/Alacritty.desktop --set-key=TryExec --set-value=$ZPFX/bin/alacritty --set-key=Exec --set-value=$ZPFX/bin/alacritty;
    sudo update-desktop-database;
    sudo mkdir -p /usr/local/share/man/man1;
    gzip -c extra/alacritty.man | sudo tee /usr/local/share/man/man1/alacritty.1.gz > /dev/null" alacritty/alacritty \
  OMZP::copybuffer \
  OMZP::git \
  OMZP::themes \
  Aloxaf/fzf-tab \
  id-as'podman-completion' has'podman' run-atpull atclone'podman completion zsh -f _podman' atpull'%atclone' zdharma-continuum/null \
  id-as"dandavison_delta_checkout" depth'1' pick"etc/completion/completion.zsh" has"delta" dandavison/delta \
  id-as'node-stuff' node'!bash-language-server;' zdharma-continuum/null \
  ;

# this group are ones that have '' and cause a shellcheck issue. figured it's better to only disable the shellcheck for those that need it?
# the id-as"*_checkout" lines are because those plugins are installed elsewhere("gh-r" or the fuzzy metaplugin or ...), but only the binary. so, we have to check out the repo for the completions and man pages
# shellcheck disable=2016
zinit wait'0b' lucid for \
  from"gh-r" sbin'fnm' atclone"chmod +x ./fnm; ./fnm completions > ~/.zinit/completions/_fnm" atload'eval "$(fnm env)"' atpull'%atclone' run-atpull Schniz/fnm \
  sbin"tmux" cloneonly atclone'sh autogen.sh; ./configure; ln -sf $PWD/tmux.1 ~/.zinit/polaris/man/man1/tmux.1' atpull'%atclone' make ver='3.3-rc' tmux/tmux \
  id-as'github-cli' from"gh-r" sbin'usr/bin/gh' atclone'ln -sf $PWD/usr/share/man/man1/* $ZPFX/man/man1' atpull'%atclone' cli/cli \
  id-as"lotabout_skim_checkout" depth'1' sbin'bin/sk-tmux' pick"shell/completion.zsh" src"shell/key-bindings.zsh" atclone'ln -sf ~/.zinit/plugins/lotabout_skim_checkout/man/man1/* $ZPFX/man/man1' atpull'%atclone' has"sk" lotabout/skim \
  ;

zinit wait'0c' lucid for \
  atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay;" atload"_zsh_autosuggest_start; bindkey '^ ' autosuggest-accept" zsh-users+fast \
  ;

# this is super slow, like 250ms slow...
zinit ice wait"0y" lucid if'[[ -f /home/me/.bni/develop.rc ]]'
zinit snippet /home/me/.bni/develop.rc

finish_load() {
  # add anything else that needs to happen after everything else is done.
  :
}
zinit wait'0z' lucid for \
  atload"finish_load" zdharma-continuum/null \
  ;

This is the entire source of my zinit stuff. I call source this_file with the contents of above from my ~/.zshrc file.

pschmitt commented 3 years ago

AFAIK zinit never created $ZPFX/man/man1 so you must run mkdir -p $ZPFX/man/man1 in your atclone ice for this to work.

It would make sense to have zinit to this for you though.

Here's what I use for gh:

zinit as"completion" \
  lucid \
  wait \
  light-mode \
  nocompile \
  from"gh-r" \
  id-as"github-cli" \
  sbin"*/bin/gh -> gh" \
  atclone'rm -f _gh;
          gh*/bin/gh completion -s zsh > _gh;
          mkdir -p $ZPFX/man/man1;
          ln -sfv gh*/share/man/man1/* $ZPFX/man/man1' \
  atpull"%atclone" \
for @cli/cli
ryaminal commented 3 years ago

Based on https://github.com/search?q=org%3Azdharma-continuum+manpath&type=commits and the change notes from https://github.com/zdharma-continuum/zinit/blob/9ea1c9bcb7a5ffc893eb09f1ee355e5cee8d1e6d/doc/CHANGELOG.md on 02-03-2018 indicate that some form of this existed at a time.

It's not a huge issue, I've decided to just do:

# create manpath, do this after sourcing zinit.zsh to we can use ZPFX?
ZPFX_MANPATH="$ZPFX/man/man1"
mkdir -p "$ZPFX_MANPATH"
# append
export MANPATH=":$ZPFX_MANPATH"

after sourcing zinit but before any further zinit commands. the shortcut of MANPATH=":ZPFX_MANPATH"(note that the assignment starts with a :, and this indicates to manpath(see man manpath and the ENVIRONMENT.MANPATH section) that the entry here is appended(can also put : at the end for a prepend and a :: for a "insert in middle").

I installed my system fresh a month ago and I don't recall creating the $ZPFX_MANPATH or having to modify MANPATH itself. My guess is that this MANPATH manipulation was removed and I'm going crazy.

If there is a desire from folks to have this, we can make it an option at install time or something. I'd be willing to do the work, but I'm curious what folks are thinking.

NICHOLAS85 commented 3 years ago

Yep looks like manpath manipulation was removed at this point: https://github.com/zdharma-continuum/zinit/commit/c74ccdfc5de7d83fc46b197f93bd7e25bfb2e3a8

pschmitt commented 3 years ago

It's not exactly gone though. This thing is really weird, I just don't get it. Here's what happens in a fresh container when you source zinit:

d751d9ee4a86# manpath
/usr/local/man:/usr/local/share/man:/usr/share/man
d751d9ee4a86# zsh
d751d9ee4a86# source /zinit.git/zinit.zsh
d751d9ee4a86# manpath
/root/.zinit/polaris/man:/usr/local/man:/usr/local/share/man:/usr/share/man

Edit: this test has been done with https://github.com/pschmitt/zinit/tree/zpfx-manpath-creation (which pretty much only ensures that ZPFX/man/man1 exits)

pschmitt commented 3 years ago

Hm. Maybe manpath iterates over every $PATH entry and add ../man/ to its search path?

Edit: yes. That seems to be the case. For the test below I removed the part in zinit.zsh where $ZPFX/bin and $ZPFX/sbin get added to $PATH

root@5d72dad591a9:/# zsh -ils -c manpath
/usr/local/man:/usr/local/share/man:/usr/share/man
root@5d72dad591a9:/# echo 'path=( "$ZPFX/bin" "${path[@]}" )' >> /root/.zshrc
root@5d72dad591a9:/# zsh -ils -c manpath
/root/.zinit/polaris/man:/usr/local/man:/usr/local/share/man:/usr/share/man
NICHOLAS85 commented 3 years ago

Interesting, manpath is missing $ZPFX/man on my machine unless I explicitly set it myself. $ZPFX/bin is included in my path aswell

pschmitt commented 3 years ago

Interesting, manpath is missing $ZPFX/man on my machine unless I explicitly set it myself. $ZPFX/bin is included in my path aswell

Are you on macOS perhaps? What version of man are you using?

The above test was with man 2.9.1 (Ubuntu 20.04.3)

NICHOLAS85 commented 3 years ago

I'm running Bedrock Linux 0.7.24beta1 Poki with Zsh and man being provided by a Fedora 35 stratum. man 2.9.4

pschmitt commented 3 years ago

Interesting:

head -n 5 /etc/man_db.conf
# man_db.conf
#
# This file is used by the man-db package to configure the man and cat paths.
# It is also used to provide a manpath for those without one by examining
# their PATH environment variable. For details see the manpath(5) man page.

I haven't set $MANPATH on any of my systems, which may very well be the reason why this works out of the box for me :)

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 3.8.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: