strang1ato / nhi

:tv: Automatically capture all potentially useful information about each executed command (as well as its output) and get powerful querying mechanism
GNU General Public License v3.0
295 stars 11 forks source link

nhi does not work on Archlinux #16

Closed hutou closed 2 years ago

hutou commented 2 years ago

Hi, This appears to be a fantastic utility.

However, following the readme, I installed nhi on ArchLinux, but it does not seem to work correctly, as the echo nhi test failed (no output).

Also, nih.bash seems to conflict with the merged_history.bash script published in http://ptspts.blogspot.com/2011/03/how-to-automatically-synchronize-shell.html to get a persistent command history, which does not work anymore if nhi.bash is sourced in .bashrc.

strang1ato commented 2 years ago

What happens if you comment out content of your .bashrc and left only source /etc/nhi/nhi.bash uncommented (and obviously restart your terminal/bash)?

does nhi works in that situation?

hutou commented 2 years ago

Same result : no output from nhi fetch {-1} I tried something else: Clone your repository

Now I get

$ echo nhi test
nhi test
$ nhi fetch {-1}
no such shell session: 0
$ 
strang1ato commented 2 years ago

Before running install file again, you need to manually reverse changes made by install.

What you basically need to do is:

Now rerun sudo -E bash ./install (after following https://github.com/strang1ato/nhi/issues/16#issuecomment-997230940) and restart you machine

hutou commented 2 years ago

Same error message : no such shell session: 0 (started from scratch, with ~/.bashrc only containing the source /etc/nhi/nhi.bash line)

strang1ato commented 2 years ago

Can you show me the content of /tmp/nhi.log file (this file is created if error occurs, if it doesn't exist that's okay. You need root access to access that file).

and can you run this command and send me the output:

getent group tty
hutou commented 2 years ago

Hi, here is the output :

$ getent group tty
tty:x:5:brltty
$ echo nhi test
nhi test
$ nhi fetch {-1}
no such shell session: 0
$ getent group tty
tty:x:5:brltty
$ sudo ls -l /tmp/nhi.log
-rw----r-T 1 root root 424 19 déc.  22:15 /tmp/nhi.log
sudo cat /tmp/nhi.log
2021-12-19 22:14:55 | process_vm_readv failed at get_shell_environ
2021-12-19 22:14:55 | no such table: 0
2021-12-19 22:15:13 | process_vm_readv failed at get_shell_environ
2021-12-19 22:15:13 | no such table: 0
2021-12-19 22:15:24 | process_vm_readv failed at get_shell_environ
2021-12-19 22:15:24 | no such table: 0
2021-12-19 22:15:27 | process_vm_readv failed at get_shell_environ
2021-12-19 22:15:27 | no such table: 0
2021-12-19 22:15:57 | process_vm_readv failed at get_shell_environ
2021-12-19 22:15:57 | no such table: 0
$ 

I ran these command inside the Kitty terminal I currently use, but got same output when run inside a gnome-terminal. Also I ran these commands with a ~/.bashrccontaining only the nhi.bash line, and after removing/reinstalling nhi and rebooting.

strang1ato commented 2 years ago

Can you run this command and send here the output:

objdump -T $(which bash) | awk -v sym=environ ' $NF == sym && $4 == ".bss"  { print $1; exit }'
hutou commented 2 years ago

Sure, here it is :

$ objdump -T $(which bash) | awk -v sym=environ ' $NF == sym && $4 == ".bss"  { print $1; exit }'
00000000000e92e0
$ 
strang1ato commented 2 years ago

What's your kernel version? and are you sure that all deps are installed?

hutou commented 2 years ago

Hmm, some additional infos from my system, which I maintain uptodate very frequently (every week or so)

$ cat /proc/version
Linux version 5.15.10-arch1-1 (linux@archlinux) (gcc (GCC) 11.1.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 17 Dec 2021 11:17:37 +0000
$ 

Is there any dependency I could check which is not listed below ? (Arch packages may be different than those of Debian family).

$ LANG=C sudo pacman -Q binutils gawk sqlite3 libsqlite3-dev libbpf libbpf-dev
binutils 2.36.1-3
gawk 5.1.1-1
sqlite 3.37.0-1
error: package 'libsqlite3-dev' was not found
libbpf 0.6.0-1
error: package 'libbpf-dev' was not found
$ 

As for libbpf-dev, I don't know, could it be the culprit ?

strang1ato commented 2 years ago

@hutou On my arch device nhi works fine without any issues, I think that I might need to install nhi on fresh and mininimal arch install. I will let you know whether I can replicate your issue.

strang1ato commented 2 years ago

@hutou Can you follow these steps: https://github.com/strang1ato/nhi/issues/13#issuecomment-987530445, and check whether nhi works after reboot

hutou commented 2 years ago

Finally, nhi works on my computer, but ... I could not identify the precise reason why it did not work after the first installation, because I made many manipulations, installations and reinstallations without results before suddenly noticing that it worked! Maybe the result of a system update?

In any case, I found that the installation of the lib32-sqlite package is not necessary for an Archlinux install.

Moreover, to answer my need for command history management (see post 1), in the/etc/nhi/nhi.bash file, I modified the line declare PROMPT_COMMAND="prompter" by declare PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND}; prompter" (and also to keep other programs using PROMPT_COMMAND working, like autojump .

Another suggestion : add "current" after the session Id when appropriate for nhi log command

Thanks for this very usefull utility.

strang1ato commented 2 years ago

Moreover, to answer my need for command history management (see post 1), in the /etc/nhi/nhi.bash file, I modified the line declare PROMPT_COMMAND="prompter" by declare PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND}; prompter" (and also to keep other programs using PROMPT_COMMAND working, like autojump .

I will try to add it in the next release

Another suggestion : add "current" after the session Id when appropriate for nhi log command

Thanks for suggestion, I will try to address that as well (although probably in some other time)