-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Unable to open fd 8 for writing, quitting" on Linux #303
Comments
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 |
Should it then be open when I source the shell wrapper? May be the problem is in it on my end. Here is the wrapper I use - may be it is the source of trouble:$> cat tools/cmdline-completion
# Universal completion script for DataLad with the core autogenerated by
# python-argcomplete and only slighly umproved to work for ZSH if sourced under
# ZSH
if [ "${ZSH_VERSION:-}" != "" ]; then
echo "I: Enabling support of bash completions for zsh"
autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit
fi
_python_argcomplete() {
local IFS='
'
COMPREPLY=( $(IFS="$IFS" COMP_LINE="$COMP_LINE" COMP_POINT="$COMP_POINT" _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" _ARGCOMPLETE=1 "$1" 8>&1 9>&2 1>/dev/null 2>/dev/null) )
if [[ $? != 0 ]]; then
unset COMPREPLY
fi
}
complete -o nospace -o default -F _python_argcomplete "datalad" But even after sourcing it I do not see fd 8 openlena:~/proj/datalad/datalad-maint
$> source tools/cmdline-completion
$> ls -l /proc/$$/fd/
total 0
0 lrwx------ 1 yoh yoh 64 May 21 09:49 0 -> /dev/pts/25
0 lrwx------ 1 yoh yoh 64 May 21 09:49 1 -> /dev/pts/25
0 lrwx------ 1 yoh yoh 64 May 21 09:49 2 -> /dev/pts/25
0 lrwx------ 1 yoh yoh 64 May 21 09:49 255 -> /dev/pts/25 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)
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. |
I have tried with a freshly regenerated wrapper which targets specific full path datalad entry point script where I explicitly added that marker on top -- the same silence$> source /tmp/datalad-argcomplete
$> cat /tmp/datalad-argcomplete
_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 \
"$1" 8>&1 9>&2 1>/dev/null 2>/dev/null) )
if [[ $? != 0 ]]; then
unset COMPREPLY
elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "$COMPREPLY" =~ [=/:]$ ]]; then
compopt -o nospace
fi
}
complete -o nospace -o default -F _python_argcomplete "/home/yoh/proj/datalad/datalad-maint/venvs/dev3/bin/datalad"
$> cat /home/yoh/proj/datalad/datalad-maint/venvs/dev3/bin/datalad
#!/home/yoh/proj/datalad/datalad-maint/venvs/dev3/bin/python
# PYTHON_ARGCOMPLETE_OK
#
# Custom simplistic runner for DataLad. Assumes datalad module
# being available. Generated by monkey patching monkey patched
# setuptools.
#
from datalad.cmdline.main import main
main()
$> /home/yoh/proj/datalad/datalad-maint/venvs/dev3/bin/datalad ins<TAB>
|
It appears that the library/executable you are using is complex and performs a lot of initialization before calling |
That looks like an old wrapper. What version of argcomplete are you running? How did you generate it? You can try manually removing 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 !
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
_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") )
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? Some additional notes which are no longer pertinent probably
re-doing everything now after
and verified that it still doesn't work by trying to complete
|
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 |
Relevant older issue: #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:
The text was updated successfully, but these errors were encountered: