Closed CarbonChauvinist closed 1 year ago
What version of neovim are you using (manual build, package manager, Appimage, Snap, ...)?
If you have several versions of nvim you can try to select one with export NVIMPAGER_NVIM=/my/version/of/nvim
.
What exactly do you mean by
but also doesn't really do anything at all either
any output on stdout or stderr, exit code?
The original error you see is from man complaining that the pager command exits with status code 2. And the actual pager command that man is using is printed and its actually a pipeline of sed and then your $MANPAGER with many local environment variables set on its command line.
So you could also try this for debugging
MANPAGER=cat man man > manpage.txt
bash -x $(which nvimpager) < manpage.txt
echo $?
What version of neovim are you using (manual build, package manager, Appimage, Snap, ...)?
I'm using the neovim-git package from the AUR which is the same package I've been using for quite some time now with no issue with nvimpager previously.
What exactly do you mean by
but also doesn't really do anything at all either
any output on stdout or stderr, exit code?
No nothing to stdout or stderr when running (though does return an error code when checking last run command status).
I am using tmux and in the examples above and elsewhere:
~ $ echo $TERM
tmux-256color
But, even outside of a tmux session here's the behavior I get:
~ $ echo $TERM
xterm-256color
~ $ nvimpager -p test.txt
^[]11;rgb:1010/3c3c/4848^[\^[[?65;4;6;18;22c
~ $ 11;rgb:1010/3c3c/484865;4;6;18;22c
So you could also try this for debugging
MANPAGER=cat man man > manpage.txt bash -x $(which nvimpager) < manpage.txt echo $?
I've tried this in different terminals I have available (sakura, foot, wezterm, gnome terminal) and each one gets the same behavior (whether in tmux or not) although with different versions of the escape codes printed out
Just in case I'm doing something off with my env variables here they are for completeness sake:
The most interesting of these is the test with the test.txt file. It does not even involve man so the problem is somewhere in nvimpager directly.
It seems to print the nvimpager help text and exit with status 2. Can you debug this with bash -x please and find out what is happening. The illegal option -- -
might be from getopts which is used by nvimpager to parse the command line which would mean the usage text is printed to stderr and the exit status is from the *)
case in the case-statement when nvimpager parses the options.
The question then is why nvimpager sees a -
option when you execute nvimpager -p test.txt
? I only get this with nvimpager --p test.txt
.
Also for completeness you can check which -a nvim nvimpager
to see if you have different versions installed somewhere. How did you install nvimpager, also the AUR package?
The most interesting of these is the test with the test.txt file. It does not even involve man so the problem is somewhere in nvimpager directly.
It seems to print the nvimpager help text and exit with status 2. Can you debug this with bash -x please and find out what is happening.
Thanks, seems to have the same issue - redirecting both stderr and stdout to a log file shows the following (see below and attached file as well which may be easier to open and see the ?control characters? that get garbled when pasting): nvimpager_p_log.txt
Also for completeness you can check
which -a nvim nvimpager
to see if you have different versions installed somewhere. How did you install nvimpager, also the AUR package?
Yes, tracking the git package and installed from AUR
~ $ which nvimpager
/usr/bin/nvimpager
~ $ pacman -Qo $(which nvimpager)
/usr/bin/nvimpager is owned by nvimpager-git 0.12.0.r1.ga1c3916-1
~ $ nvimpager -v
nvimpager 0.12.0-1-ga1c3916
As an aside, I also did log in to my system as a new user just to be sure that something in my current user's environment wasn't somehow affecting, and I ran into the same issue with the new user too.
The strange thing is that the help output from nvimpager only appears when we try to run nvim in the end. Do you have some alias or shell function or so for exec
?
No, exec is the standard builtin TMK
~ $ type -a exec
exec is a shell builtin
Not great at parsing strace output, might be helpful to you though? When I have some more time this evening I'll start combing through this... strace.txt
I am not experienced in reading strace output. But the help text we see really appears after calling execve on neovim but apparently nvimpager is not executed in between?
Does this also happen with the defaul neovim package? On NixOS I can use neovim from the upstream git repo and nvimpager works fine with it (the nightly package in the flake.nix in this repo).
So removing the -a nvimpager
from the final exec invocation in /usr/bin/nvimpager seems to at least allow nvimpager to work. I can't say what other effects that may have - not sure if/why/when nvim's behavior changed WRT to handling the zeroth argument name override?
~ $ (exec -a foo nvim)
E903: Process failed to start: no such file or directory: "foo"Segmentation fault (core dumped)
~ $ (exec -a foo nvim -v)
NVIM v0.10.0-dev-635+ga0c9c04f00
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Run "nvim -V1 -v" for more info
~ $ stat test.txt
File: test.txt
Size: 75 Blocks: 8 IO Block: 4096 regular file
Device: 254,1 Inode: 5507337 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ ghost) Gid: ( 1000/ ghost)
Access: 2023-07-05 22:07:17.557736553 -0400
Modify: 2023-07-04 09:24:53.430140930 -0400
Change: 2023-07-04 09:24:53.430140930 -0400
Birth: 2023-07-04 09:24:53.430140930 -0400
~ $ (exec -a foo nvim test.txt)
E903: Process failed to start: no such file or directory: "foo"Segmentation fault (core dumped)
~ $ (exec nvim test.txt)
# neovim opens successfully with the test..txt file
~ $ (exec -a foo nvim --headless -c '!cat test.txt')
:!cat test.txt
this is a sample text file
with just a couple of lines
here's another line
So not sure, but it seems that using exec -a with nvim in some instances causes a core dump? and other times it doesn't?
I'll try with the neovim from the standard repos and let you know.
You could also try this with a neovim that you build manually from the upstream sources. Maybe it is a bug with the neovim-git package?
Thanks - switching to regular neovim package from standard arch repos and the issue was gone with nvimpager. Similarly using the neovim-nightly-bin package also got rid of the issue.
Caused me to investigate the neovim-git package closer, turns out there were some changes I'd made some time ago to the PKGBUILD to test some ideas that I never reverted that were the root cause for this issue.
Edit -- actually that's not the case. The edits I was playing around with in the neovim-git PKGBUILD was not what I'd actually installed to my system when I had the issue. Somehow, somewhere in installing the regular neovim and neovim-nightly-bin and then reinstalling neovim-git to test more, this issue disappeared for me.
Either way, very embarrassing; apologies for the noise and time sink, and thanks for this awesome project.
Just came here to say thanks for getting the exec -a issue fixed in neovim master!
Also a small close out of this issue report...
Going back through my steps reporting this issue, when testing I'd made the change to nvimpager to remove the -a flag from the exec command in /usr/bin/nvimpager and forgot to put it back in
So that's why after the carousel of different neovim versions (regular, neovim-nightly-bin, neovim-git) the issue appeared to be fixed for me -- it actually wasn't I'd just removed the cause of the neovim crash from the nvimpager invocation.
Since the fix applied to neovim (commit 559c4cfd52), and making sure I'm running the unmodified version of nvimpager -- all works as expected.
The only thing that's still a mystery to me, is that you said you weren't experiencing the issue when running with the neovim-nightly version on nix? Wonder how that happened.. probably a moot point now that neovim has applied the fix though.
All the best.
NixOS wraps many executables in shell scripts and the nvim shell script uses exec -a itself so it overrides the argv0 from nvimpager.
Similar to issue #32 I've recently been getting the following error when trying to use nvimpager.
Possibly relevant info:
``` ~ $ which nvim /usr/bin/nvim ~ $ nvim -v NVIM v0.10.0-dev-618+g4fd852b8cb Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Run "nvim -V1 -v" for more info ~ $ nvimpager -v nvimpager 0.12.0-1-ga1c3916 ~ $ grep -E ^[^#].*PAGER .bashrc export PAGER=/usr/bin/nvimpager export MANPAGER=/usr/bin/nvimpager export DELTA_PAGER=less ~ $ cat .config/nvimpager/init.vim let mapleader = "," set ignorecase set smartcase set number set cursorline nnoremapHere's a bash trace for trying to access a man page
``` ~ $ MANPAGER="bash -x nvimpager" man nvimpager + RUNTIME=/usr/share/nvimpager/runtime + PARENT=27554 + TMPFILE= + export RUNTIME + export PARENT + export TMPFILE + export NVIM_APPNAME=nvimpager + NVIM_APPNAME=nvimpager + mode=auto + nvim=nvim + getopts achpv flag + shift 0 + [[ 0 -eq 0 ]] + [[ -t 0 ]] + [[ ! -t 1 ]] + files=() + stdin=false + [[ 0 -gt 0 ]] + [[ -z '' ]] + [[ 0 -eq 0 ]] + [[ ! -t 0 ]] ++ mktemp + TMPFILE=/tmp/tmp.p0P8wMDlbb + files=("$TMPFILE") + [[ -n /tmp/tmp.p0P8wMDlbb ]] + trap 'rm -f "$TMPFILE"' EXIT + cat + args1=(-R --cmd 'set rtp+=$RUNTIME | lua nvimpager = require("nvimpager")') + args2=(--cmd 'lua nvimpager.stage1()' -c 'lua nvimpager.stage2()') + [[ auto = cat ]] + [[ auto = auto ]] ++ cat /tmp/tmp.p0P8wMDlbb ++ wc -l ++ tput lines + [[ 117 -le 36 ]] + exec -a nvimpager nvim -R --cmd 'set rtp+=$RUNTIME | lua nvimpager = require("nvimpager")' /tmp/tmp.p0P8wMDlbb --cmd 'lua nvimpager.stage1()' -c 'lua nvimpager.stage2()' man: command exited with status 2: sed -e '/^[[:space:]]*$/{ N; /^[[:space:]]*\n[[:space:]]*$/D; }' | LESS=-ix8RmPm Manual page nvimpager(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page nvimpager(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$ MAN_PN=nvimpager(1) bash -x nvimpager ```And here's one just trying to use as a pager, which interestingly, doesn't error out the same way as man attempt does, but also doesn't really do anything at all either:
``` ~ $ bash -x nvimpager .bashrc + RUNTIME=/usr/share/nvimpager/runtime + PARENT=21108 + TMPFILE= + export RUNTIME + export PARENT + export TMPFILE + export NVIM_APPNAME=nvimpager + NVIM_APPNAME=nvimpager + mode=auto + nvim=nvim + getopts achpv flag + shift 0 + [[ 1 -eq 0 ]] + [[ ! -t 1 ]] + files=() + stdin=false + [[ 1 -gt 0 ]] + [[ -f .bashrc ]] + files+=("$1") + shift + [[ 0 -gt 0 ]] + [[ -z '' ]] + [[ 1 -eq 0 ]] + [[ -n '' ]] + args1=(-R --cmd 'set rtp+=$RUNTIME | lua nvimpager = require("nvimpager")') + args2=(--cmd 'lua nvimpager.stage1()' -c 'lua nvimpager.stage2()') + [[ auto = cat ]] + [[ auto = auto ]] ++ cat .bashrc ++ wc -l ++ tput lines + [[ 156 -le 36 ]] + exec -a nvimpager nvim -R --cmd 'set rtp+=$RUNTIME | lua nvimpager = require("nvimpager")' .bashrc --cmd 'lua nvimpager.stage1()' -c 'lua nvimpager.stage2()' ```Unfortunately, I can't say exactly when this stopped working for me...