-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Clashes with gcloud bash/zsh completion _python_argcomplete() #310
Comments
The fault here is definitely Google's but for a workaround that you do not have to re-apply after an update, run the i.e. in your bashrc, instead of sourcing the . <(sed -E 's/(^| )(_python_argcomplete)(\(\)| )/\1_gcloud\2\3/g' \
/usr/lib/google-cloud-sdk/completion.bash.inc) If Google ever fixes the issue by adding their own prefix/suffix to the function name, the sed above should become a no-op so it won't break. |
Thanks for the suggested workaround @algorythmic. We could also fix this in argcomplete by using a unique function name per executable, which we're actually already doing for fish (though I'm not exactly sure why). Unfortunately I don't have time to implement and test this, but I could help out with a review if someone wanted to contribute the feature. |
I was about to try and implement what's already done for fish but for bash, That argument can be used as:
It generates:
And it no longer clashes with the gcloud completion functions. |
Anyway, submitted #320 to always suffix the bash function. |
On the face of it, this does not look like a bug in argcomplete. If I understand correctly, gcloud vendors argcomplete and ends up forcing its argcomplete installation on the rest of the system. The bash namespace is global, and we have to accept any interference from other software stomping on our names or incorrectly vendoring us and causing interference between different vendored and unvendored versions of ourselves. Perhaps the solution here is to provide an argcomplete vendoring guide, but I'm not entirely sure what we'd write there. The solution proposed here and in #320 does not accomplish the goal of namespace isolation either between completion targets or between argcomplete versions (there are still other functions defined in the shellcode - I'm not at all convinced that isolating between completion targets by creating one completion function per target is the right thing to do (it seems wasteful to load all these different functions into memory if there are a lot of targets). I am more amenable to isolating between argcomplete versions. Imagining how this would work, ALL shell functions defined by argcomplete would need to have, in their name, the version of argcomplete that installed them (for example, But I'm not sure if that's necessary or advisable either. I can imagine the solution above causing dependency hell types of issues and broken installations with cryptic errors when someone installs a bunch of completion shellcode and then upgrades Python or argcomplete. I'd look for guidance to other software that has to deal with global namespacing in shellcode, including other bash-completion modules. I would welcome any pointers on how they deal with this kind of situation, if at all. I'm closing this bug and PR for now. If you want an update to be considered here, please provide a clear design rationale and background on why it's needed, how it will prevent a problem like this from reoccurring in the future, how it will behave when many completion targets are registered, and how it will behave when Python or argcomplete are upgraded. |
Hi,
the
_python_argcomplete()
shell function defined by Google's gcloud SDK completion is clashing with the one defined by argcomplete: https://issuetracker.google.com/issues/147687442#comment12A work-around is to patch the gcloud defined function to suffix it and avoid the clash, but that needs to be done on each update:
I'm basically looking for alternative solutions to definitively fix the issue. Any ideas?
The text was updated successfully, but these errors were encountered: