Closed electriquo closed 6 months ago
Hmm..
You've got this issue on Linux and OSX? Anything in your .bashrc
that might interfere with carapace?
Which Bash version have you?
You've got this issue on Linux and OSX?
Yes.
Anything in your .bashrc that might interfere with carapace?
declare -F | grep -E '^(declare -f ){1}(get|(un)?set|_carapace){1}'
shows that Carapace functions are there but nothing happens when trying to use Carapace (using git sh
then pressing the tab key)
Which Bash version have you?
5.2.26
So on both systems it works when you put it into ~/.bash_profile
or call it manually in a running shell with source <(carapace _carapace)
?
If so I'd assume there is either some interferance with other entries in .bashrc
or the shell isn't correctly detected (use source <(carapace _carapace bash)
).
The functions being present as you wrote should mean that the detection is fine though :thinking: .
Debugging reveals that having Carpace setup line before/after the line where ~/.bash
loads completion files makes the difference. There are 40 completion files that are loaded and I wonder what is the most efficient way to find which one and maybe then why there is a collision.
@rsteube When I execute source <(carapace _carapace)
within the active shell, then using git sh
... pressing the tab activates the builtin completion of Git. But when I press tab 2 times, then Carapace completion get activated for the first time. Do you have any lead why? Maybe this is the source of the issue...
Carapace has a 2-step process registering the completion:
_carapace_lazy() { # initial script registered for completion
source <(carapace $1 bash) # source actual completion script on first tab (e.g. for git)
$"_$1_completion" # execute the actual completion script (function) so that they are returned for the first tab as well
}
There could be something interfering with line 3 calling the old script. But I haven't encountered something like this in a long time (did in the past though).
Try sourcing just the git completion in a fresh shell and see if that works on the first tab:
source <(carapace git bash)
Try sourcing just the git completion in a fresh shell and see if that works on the first tab:
source <(carapace git bash)
This did not help and couldn't debug the issue
Any idea how tell what conflicts with Carapace?
Not at the moment.
In Fish there's an issue where the file based system completions are always loaded. So when you register a completion and then try to TAB complete the system one gets loaded and overwrites the previously registered one. I could imagine someting similar happening here, but I don't have this issue with Bash on any of my systems :thinking: .
Which Linux is this? Is it possible to reproduce it in a docker container?
Is it possible to reproduce it in a docker container?
I am sure it is possible, but it seems to me like lots of work. Will try to look into it and report back.
Which Linux is this?
macOS at the moment.
Investigation shows clearly that if a builtin completion (such as git) are loaded after source <(carapace _carapace)
, then Carapace completion will not kick in for the loaded completion (such as git).
This can be easily verified, the following will not let Carapace kick in
source <(carapace _carapace)
source /usr/share/bash-completion/completions/git
Whereas, the following will let Carapace kick in
source /usr/share/bash-completion/completions/git
source <(carapace _carapace)
@rsteube Any insights?
That is normal behaviour. By sourcing the completion file you are registering a different function for git
.
Following https://github.com/carapace-sh/carapace-bin/issues/2387#issuecomment-2131213580 and
Then Carapace setup much occur after loading all shell completion. To guarantee this is always the case, what stated holds
So it is fine now?
So it is fine now?
It was always fine if Carapace setup is added at the very end of the profile :) Maybe worth mentioning it in the docs, to save your and others time.
Thank you @rsteube
Current Behavior
I read Bash setup guide and tried to setup Carapace into my shell. Carapace didn't work for me although the its function were there
I was looking whether something overridden or has a conflict with Caraspace, but there was none. The only thing that worked for me, was placing the setup commands at the very end of my shell profile file.
Expected Behavior
Carapace setup could appear anywhere on the shell profile files and still get activated
Steps To Reproduce
declare -F | grep -E '^(declare -f ){1}(get|(un)?set|_carapace){1}'
to verify Carapace setup occurredgit sh
and press the tab keyAssumptions
~/.bash_profile
exists, non-empty, has commands in it excluding Carapace setuo and is loaded when the user logs inAdd Carapace
The following will add Carapace setup at the first line of the
~/.bash_profile
file if it is not already thereRemove Carapace
The following will remove Carapace when it was added as above
Version
1.0.2
OS
Shell
Anything else?
No response