alexherbo2 / kakoune.cr

A command-line tool for Kakoune
https://kakoune.org
The Unlicense
54 stars 11 forks source link

Errors leave fifo/pipes behind #11

Closed ghost closed 3 years ago

ghost commented 3 years ago

Running many kcr commands in an incorrect way leaves behind a fifo/named pipe in the current directory. If not removed these can clutter and cause a mess. Would it be possible to instead place them in the /tmp folder where they would not be likely to cause issues and would eventually not require manual removal?

alexherbo2 commented 3 years ago

How can I reproduce?

FIFOs are normally generated using File.tempname.

Example

crystal eval 'puts File.tempname'
# /run/user/1000/20210316-20946-r2p2z2
ghost commented 3 years ago

Been playing with it more and whilst for me crystal eval 'puts File.tempname' usually correctly outputs something like /tmp/20210316-11394-1qcbr4k, for some reason, when run in a shell spawned by kakoune (kcr doesnt matter) crystal eval 'puts File.tempname' will simply output something like: 20210316-11762-78pds8 causing it to be created in the current directory. This actually breaks many kcr commands as if the shells current directory is different from kakounes then the pipe is opened and never written to as kakoune instead writes them to a new text file of the same name in its directory.

So this is a problem of how shells spawned by kakoune handle it differently for some reason. I am unsure if this maybe something wrong with my configuration, although opening a kakoune session with no kakrc after renaming it and then initing kcr leads to the same problems.

edit: just tested some more and it only occurs in tmux panes/windows that kakoune spawns. Normal terminals such as those made with popup work normally. Normal tmux panes/windows that kakoune doesn't spawn work normally too, only those kakoune creates have problems

edit 2: It does not occur in panes created by tmux-repl, only ones created with tmux-terminal

edit 3: looking at the differences between tmux.kak and repl/tmux.kak, for some reason tmux-terminal has this in the tmux command env TMPDIR="$TMPDIR". I checked and my TMPDIR environment variable is blank, setting it to /tmp/ before running kak fixes everything. Unsure why tmux-terminal has this in its command though

alexherbo2 commented 3 years ago

To sum up, the culprit is tmux.kak which sets your TMPDIR to an empty value?

ghost commented 3 years ago

My TMPDIR is normally empty, but it didnt cause problems until tmux.kak sets it to be nothing again and breaks it for some reason. So long as its not empty originally it works fine. I've just set it in my bashrc now so its all fixed

alexherbo2 commented 3 years ago

I think it is because the variable is set and visible by env.

Your TMPDIR is normally not set, but tmux.kak sets it to an empty value, resulting the bug.

It can be verified with the following command:

env | grep TMPDIR
ghost commented 3 years ago

Ah, yes that seems to be what's happening, thanks.

alexherbo2 commented 3 years ago

Closing, as not a bug from kakoune.cr: it correctly honors the TMPDIR value.

alexherbo2 commented 3 years ago

@Elither Do you mind opening an issue upstream? It looks @topisani has the same problem.

ghost commented 3 years ago

https://github.com/mawww/kakoune/issues/4161