Comments (12)
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.
from nvimpager.
NixOS wraps many executables in shell scripts and the nvim shell script uses exec -a itself so it overrides the argv0 from nvimpager.
from nvimpager.
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 $?
from nvimpager.
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).
Here's an example:
~ $ cat test.txt
this is a sample text file
with just a couple of lines
here's another line
~ $ nvimpager -p test.txt
# notice no output
~ $ echo $?
2
~ $ nvimpager -p test.txt &> nvimpager_log.txt
# here I had to go into neovim to read the log file as trying to cat to screen gives me some issues
# looks like there is some escape/terminal codes getting injected somehow?
# Here's the file's contents opened in neovim and pasted below
# note all the missing glyphs below are shown as '^['
# that's two (2) characters, caret and left-bracket in neovim but get garbled when pasted here:
�[?1049h�[?1h�=�[H�[J�]11;?��[?2004h�[?u�[c�[34h�[?25h/usr/bin/nvimpager: illegal option -- -
Usage: nvimpager [-acp] [--] [nvim options and files]
nvimpager -h
nvimpager -v
�[?25l�[23B�[m��[34h�[?25h�[?1l�>�[?1049l�[?2004l�[?1004l�[34h�[?25h
and here's what happens when I try to cat to screen:
~ $ cat nvimpager_log.txt
^[[?1;2c
~ $ 1;2c
~ $ 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 $?
Thanks for this, here's the output
~ $ MANPAGER=cat man wc > wc_manpage.txt
~ $ bash -x $(which nvimpager) < wc_manpage.txt
+ 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
+ [[ 0 -eq 0 ]]
+ [[ -t 0 ]]
+ [[ ! -t 1 ]]
+ files=()
+ stdin=false
+ [[ 0 -gt 0 ]]
+ [[ -z '' ]]
+ [[ 0 -eq 0 ]]
+ [[ ! -t 0 ]]
++ mktemp
+ TMPFILE=/tmp/tmp.sMH5rpujnr
+ files=("$TMPFILE")
+ [[ -n /tmp/tmp.sMH5rpujnr ]]
+ 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.sMH5rpujnr
++ wc -l
++ tput lines
+ [[ 58 -le 48 ]]
+ exec -a nvimpager nvim -R --cmd 'set rtp+=$RUNTIME | lua nvimpager = require("nvimpager")' /tmp/tmp.sMH5rpujnr --cmd 'lua nvimpager.stage1()' -c 'lua nvimpager.stage2()'
~ $ echo $?
2
I used wc as test because it seemed relatively short as far as man pages go:
~ $ bash -x $(which nvimpager) < wc_manpage.txt &> wc_manpage_log.txt
# now I can successfully cat to screen the output of the file
~ $ cat wc_manpage_log.txt
+ 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
+ [[ 0 -eq 0 ]]
+ [[ -t 0 ]]
+ [[ ! -t 1 ]]
+ [[ auto = auto ]]
+ exec cat
WC(1) User Commands WC(1)
NAME
wc - print newline, word, and byte counts for each file
SYNOPSIS
wc [OPTION]... [FILE]...
wc [OPTION]... --files0-from=F
DESCRIPTION
Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified. A word is a non-zero-length sequence of printable characters delimited by white space.
With no FILE, or when FILE is -, read standard input.
The options below may be used to select which counts are printed, always in the following order: newline, word, character, byte, maximum line length.
-c, --bytes
print the byte counts
-m, --chars
print the character counts
-l, --lines
print the newline counts
--files0-from=F
read input from the files specified by NUL-terminated names in file F; If F is - then read names from standard input
-L, --max-line-length
print the maximum display width
-w, --words
print the word counts
--total=WHEN
when to print a line with total counts; WHEN can be: auto, always, only, never
--help display this help and exit
--version
output version information and exit
AUTHOR
Written by Paul Rubin and David MacKenzie.
REPORTING BUGS
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
COPYRIGHT
Copyright © 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
Full documentation <https://www.gnu.org/software/coreutils/wc>
or available locally via: info '(coreutils) wc invocation'
GNU coreutils 9.3 April 2023 WC(1)
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
Example here's gnome terminal in a non tmux session
~ $ man wc
man: command exited with status 2: sed -e '/^[[:space:]]*$/{ N; /^[[:space:]]*\n[[:space:]]*$/D; }' | LESS=-ix8RmPm Manual page wc(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page wc(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$ MAN_PN=wc(1) /usr/bin/nvimpager
^[]11;rgb:ffff/ffff/ffff^G^[[?65;1;9c
~ $ 11;rgb:ffff/ffff/ffff65;1;9c
And here's sakura in a non tmux session
~ $ man wc
man: command exited with status 2: sed -e '/^[[:space:]]*$/{ N; /^[[:space:]]*\n[[:space:]]*$/D; }' | LESS=-ix8RmPm Manual page wc(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page wc(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$ MAN_PN=wc(1) /usr/bin/nvimpager
^[]11;rgb:0000/0000/0000^G^[[?65;1;9c
~ $ 11;rgb:0000/0000/000065;1;9c
Just in case I'm doing something off with my env variables here they are for completeness sake:
printenv | sort
AURDEST=/pkg/aur/aurutils/sync
_CE_CONDA=
_CE_M=
CHROOT=/home/ghost/chroot
COLUMNS=192
CONDA_EXE=/opt/miniconda3/bin/conda
CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
CONDA_SHLVL=0
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DEBUGINFOD_URLS=https://debuginfod.archlinux.org
DELTA_PAGER=less
DESKTOP_SESSION=gnome
DISPLAY=:0
DOTNET_BUNDLE_EXTRACT_BASE_DIR=/home/ghost/.cache/dotnet_bundle_extract
DOTNET_ROOT=/usr/share/dotnet
EDITOR=nvim
FORGIT_GI_REPO_LOCAL=/home/ghost/.forgit/gi/repos/dvcs/gitignore
FORGIT_GI_REPO_REMOTE=https://github.com/dvcs/gitignore
FORGIT_GI_TEMPLATES=/home/ghost/.forgit/gi/repos/dvcs/gitignore/templates
FZF_CTRL_T_COMMAND=rg --files --hidden --no-ignore --ignore-file /home/ghost/.telescope_gitignore
FZF_DEFAULT_COMMAND=rg --files --hidden --no-ignore --ignore-file /home/ghost/.telescope_gitignore
FZF_DEFAULT_OPTS=--layout=reverse --border
GDM_LANG=en_US.UTF-8
GDMSESSION=gnome
GEM_HOME=/home/ghost/.local/share/gem/ruby/3.0.0
GNOME_SETUP_DISPLAY=:1
HG=/usr/bin/hg
HOME=/home/ghost
INVOCATION_ID=b6e05ac67607462494b32b55988859bb
JOURNAL_STREAM=8:25831
LANG=en_US.UTF-8
LIBVA_DRIVER_NAME=iHD
LIBVA_DRIVERS_PATH=/usr/lib/dri
LOGNAME=ghost
LS_COLORS=:ow=1;7;34:st=30;44:su=30;41
MAIL=/var/spool/mail/ghost
MANAGERPID=993
MANPAGER=/usr/bin/nvimpager
MANWIDTH=999
MOTD_SHOWN=pam
MOZ_ENABLE_WAYLAND=1
mssql_jdbc_test_connection_properties=jdbc:sqlserver://localhost;user=ghost
npm_config_prefix=/home/ghost/.node_modules
OLDPWD=/home/ghost/.aur/neovim-git
PAGER=/usr/bin/nvimpager
PATH=/opt/miniconda3/condabin:/usr/local/bin:/usr/bin:/usr/local/sbin:/home/ghost/.dotnet/tools:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/ghost/.local/bin:/home/ghost/.local/bin/scripts:/home/ghost/.node_modules/bin:/home/ghost/go/bin:/home/ghost/.cargo/bin:/home/ghost/.local/share/gem/ruby/3.0.0/bin:/home/ghost/.local/bin:/home/ghost/.local/bin/scripts:/home/ghost/.node_modules/bin:/home/ghost/go/bin:/home/ghost/.cargo/bin:/home/ghost/.local/share/gem/ruby/3.0.0/bin
PWD=/home/ghost
QT_QPA_PLATFORM=wayland
SESSION_MANAGER=local/lap:@/tmp/.ICE-unix/1095,unix/lap:/tmp/.ICE-unix/1095
SHELL=/bin/bash
SHLVL=0
SSH_AUTH_SOCK=/run/user/1000/ssh-agent.socket
SYSTEMD_EXEC_PID=1449
TERM_PROGRAM=tmux
TERM_PROGRAM_VERSION=3.3a
TERM=tmux-256color
TMUX_PANE=%1
TMUX_PLUGIN_MANAGER_PATH=/home/ghost/.tmux/plugins/
TMUX=/tmp/tmux-1000/default,1471,0
USER=ghost
USERNAME=ghost
_=/usr/bin/printenv
VISUAL=nvim
WAYLAND_DISPLAY=wayland-0
XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.ORWS71
XDG_CURRENT_DESKTOP=GNOME
XDG_DATA_DIRS=/home/ghost/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/
XDG_MENU_PREFIX=gnome-
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_CLASS=user
XDG_SESSION_DESKTOP=gnome
XDG_SESSION_TYPE=wayland
from nvimpager.
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?
from nvimpager.
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
bash -x nvimpager -p test.txt &> nvimpager_p_log.txt
+ RUNTIME=/usr/share/nvimpager/runtime
+ PARENT=1619
+ TMPFILE=
+ export RUNTIME
+ export PARENT
+ export TMPFILE
+ export NVIM_APPNAME=nvimpager
+ NVIM_APPNAME=nvimpager
+ mode=auto
+ nvim=nvim
+ getopts achpv flag
+ case $flag in
+ mode=pager
+ getopts achpv flag
+ shift 1
+ [[ 1 -eq 0 ]]
+ [[ ! -t 1 ]]
+ [[ pager = auto ]]
+ files=()
+ stdin=false
+ [[ 1 -gt 0 ]]
+ [[ -f test.txt ]]
+ 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()')
+ [[ pager = cat ]]
+ [[ pager = auto ]]
+ exec -a nvimpager nvim -R --cmd 'set rtp+=$RUNTIME | lua nvimpager = require("nvimpager")' test.txt --cmd 'lua nvimpager.stage1()' -c 'lua nvimpager.stage2()'
�[?1049h�[?1h�=�[H�[J�]11;?��[?2004h�[?u�[c�[34h�[?25h/usr/bin/nvimpager: illegal option -- -
Usage: nvimpager [-acp] [--] [nvim options and files]
nvimpager -h
nvimpager -v
�[?25l�[23B�[m��[34h�[?25h�[?1l�>�[?1049l�[?2004l�[?1004l�[34h�[?25h
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.
from nvimpager.
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
?
from nvimpager.
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
from nvimpager.
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).
from nvimpager.
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?
$ coredumpctl info 29392
PID: 29392 (nvim)
UID: 1000 (ghost)
GID: 1000 (ghost)
Signal: 11 (SEGV)
Timestamp: Thu 2023-07-06 02:22:43 EDT (2min 9s ago)
Command Line: foo --
Executable: /usr/bin/nvim
Control Group: /user.slice/user-1000.slice/[email protected]/app.slice/tmux.service
Unit: [email protected]
User Unit: tmux.service
Slice: user-1000.slice
Owner UID: 1000 (ghost)
Boot ID: 4c11dc14a17844ae91e3147ae53e14d5
Machine ID: dc8f42fd534f4e889cfc1102ec51adff
Hostname: lap
Storage: /var/lib/systemd/coredump/core.nvim.1000.4c11dc14a17844ae91e3147ae53e14d5.29392.1688624563000000.zst (present)
Size on Disk: 193.8K
Message: Process 29392 (nvim) of user 1000 dumped core.
Stack trace of thread 29392:
#0 0x0000559f07c1f956 ui_client_start_server (nvim + 0x2c0956)
#1 0x0000559f079d8d86 main (nvim + 0x79d86)
#2 0x00007fb426823ad0 n/a (libc.so.6 + 0x23ad0)
#3 0x00007fb426823b8a __libc_start_main (libc.so.6 + 0x23b8a)
#4 0x0000559f079d4045 _start (nvim + 0x75045)
Stack trace of thread 29393:
#0 0x0000000000000000 n/a (n/a + 0x0)
ELF object binary architecture: AMD x86-64
I'll try with the neovim from the standard repos and let you know.
from nvimpager.
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?
from nvimpager.
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.
from nvimpager.
Related Issues (20)
- Config option for pager mode always HOT 2
- bad ansi escape sequences parsing? HOT 15
- Strange characters instead of underline HOT 2
- Doesn't work with neovim from snap HOT 5
- Still changing the cursor even after `guicursor` is set to empty string HOT 10
- nvimpager fails when executed without options in a script HOT 5
- Install fails on nixos (`0.11.0`) HOT 2
- R help displayed incorrectly HOT 3
- When wrapping with Nix to set arguments, always uses `cat` mode HOT 7
- diff file type detected as man HOT 5
- Git diff uses "Identifier" highlight group for "Adding" lines HOT 1
- Is it possible to use pure lua to refactor this project? HOT 3
- display number like bat HOT 1
- How to display the code fence if the markdown? HOT 1
- Unrecognised option in busybox HOT 1
- broken tests on neovim 0.10.0 HOT 3
- Font Ligatures HOT 2
- `cat` mode stopped colorising syntax HOT 8
- Wrapped URLs fail HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvimpager.