Open yarikoptic opened 4 years ago
This is expected; you cannot open a file descriptor if it doesn't exist. The shell wrappers explicitly create and read from file descriptor 8. We do this because argcomplete lives within arbitrary Python programs, so rather than trying to suppress all output to stdout, we simply redirect the stream to /dev/null and communicate on a different one.
Your actual problem likely has nothing to do with this. Can you set _ARC_DEBUG=1
and paste the output from an actual tab completion attempt? Please also provide your shell version and what you did to install and activate argcomplete.
The shell wrappers explicitly create and read from file descriptor 8
Should it then be open when I source the shell wrapper? May be the problem is in it on my end.
Should fd 8 be open at that point already or that would happen later? (upon attempt to complete?)
may be there is some shell setting which is in a way...?(btw -- tried with both bash and zsh)
Can you set _ARC_DEBUG=1 and paste the output from an actual tab completion attempt?
Note that in the initial report message I already have that env var set. And that is how I actually arrived to this specific issue -- by use of this env var... But here is plain attempt to complete which is not informative really:
(git)lena:~datalad/datalad-maint[maint]
$> source venv*/dev3/bin/activate
$> export _ARC_DEBUG=1
$> source tools/cmdline-completion
I: Enabling support of bash completions for zsh
$> datalad ins<TAB>
no matches for: `file' or `corrections'
so nothing is shown.
It appears that the library/executable you are using is complex and performs a lot of initialization before calling argcomplete.autocomplete()
. Some of these initialization steps may be interfering with the argcomplete protocol by using fd 8 or otherwise. The solution to your issue is to disable these initialization steps that your executable is running between the entry point and calling argcomplete, until argcomplete starts working.
That looks like an old wrapper. What version of argcomplete are you running? How did you generate it?
You can try manually removing 1>/dev/null 2>/dev/null
from the line where it runs your program to see if it outputs anything when you attempt to tab complete it.
Have you been able to get any other simple test programs working with argcomplete?
THANK YOU @evanunderscore for the guidance -- I am ready to declare "success" in troubleshooting !
What version of argcomplete are you running?
since it is argcomplete which generates it, may be it should embed argcomplete version which generated it somewhere in the comment
TL;DR summary: it is interaction between
IFS=$'\013'
which is later 'exported' into the underlying process:_python_argcomplete() {
local IFS=$'\013'
local SUPPRESS_SPACE=0
if compopt +o nospace 2> /dev/null; then
SUPPRESS_SPACE=1
fi
COMPREPLY=( $(IFS="$IFS" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
COMP_TYPE="$COMP_TYPE" \
_ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" \
_ARGCOMPLETE=1 \
_ARGCOMPLETE_SUPPRESS_SPACE=$SUPPRESS_SPACE \
__python_argcomplete_run "$1") )
git-annex
standalone (filed fresh bug report) to @joeyh build shim showing intolerance to that IFS
causing it to segfault.$> IFS=$'\013' /usr/lib/git-annex.linux/git version
[1] 1039928 segmentation fault (core dumped) IFS=$'\013' /usr/lib/git-annex.linux/git version
That also explains why other @datalad/developers didn't experience this -- since they typically do not use standalone git-annex build.
I guess there is nothing wrong done on argcomplete side, so feel free to close this issue, unless you see that you could avoid setting IFS and set some other "argcomplete specific" variable so it might not cause disturbance in some weak tools underneath?
Thanks for the detailed notes @yarikoptic. Glad you managed to find the source of your problem!
Embedding the argcomplete version in the generated wrapper is a good idea, though currently argcomplete doesn't have a __version__
and keeping one in sync with the package version number is a workflow problem that would need to be left to @kislyuk.
Relevant older issue: https://github.com/kislyuk/argcomplete/issues/142 where I believe users also reported it happening on Linux but it was closed without any resolution (e.g. via suggested use of temporary files).
In my case I have a stock Debian (testing/unstable mix), python 3.8.3rc1 and I observe the same error with our DataLad which recently was fixed up to work (again) with argcomplete and it works for everyone else on the team but (un)lucky me. In the session you below can see that I am getting the exception, and the process has no 8 fd among its fds:
in the shell I do get calls which do not explicitly create fd 8 failing: