stecman / symfony-console-completion

Automatic tab-key completion for Symfony console application options, arguments and parameters
MIT License
421 stars 26 forks source link

"-bash: __ltrim_colon_completions: command not found" #36

Closed ezzatron closed 7 years ago

ezzatron commented 9 years ago

I've had success getting this library to work under zsh, but in two different installations of bash, no luck. For both my OSX machine (GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin14)), and a dev environment (GNU bash, version 4.2.45(1)-release (x86_64-pc-linux-gnu)) I get the following errors:

bash: __ltrim_colon_completions: command not found
bash: _get_comp_words_by_ref: command not found

If I can assist with any further information, please let me know.

stecman commented 9 years ago

Hi @ezzatron, do you have bash-completion installed in either environment? Both of those functions are provided by it, which suggests it's either not installed or not being loaded. Also, see #13.

ezzatron commented 9 years ago

That seems to be the problem. Unfortunately Macports doesn't provide bash-completion for the standard OSX bash installation, so I'll have to ask people to switch to the Macports version of bash, which is a bit unfortunate. Thanks for the reply.

stecman commented 9 years ago

Ok cool. If you leave this ticket open, I'll have a look into removing the dependency on those functions from bash-completion; they were added to prevent colons from acting as word breaks, but there's probably a solution that doesn't require their use.

aik099 commented 9 years ago

That seems to be the problem. Unfortunately Macports doesn't provide bash-completion for the standard OSX bash installation, so I'll have to ask people to switch to the Macports version of bash, which is a bit unfortunate. Thanks for the reply.

I've installed it via brew. However it was a bit tricky, because I need to manually create /etc/profile.d folder and place auto-complete initialization script there for that to work. Here are some manual: http://www.dowdandassociates.com/blog/content/howto-set-an-environment-variable-in-mac-os-x-terminal-only/

stecman commented 9 years ago

It's also worth noting that bash-completion should be pretty straight forward to install from source.

ezzatron commented 9 years ago

If it's feasible, removing the dependency sounds awesome. I wouldn't have to convince my sysadmins to install bash-completion everywhere, for one thing.

aik099 commented 8 years ago

The #58 added protection code, so that you'll get nice error, when attempting to use auto-complete, when no Bash Completion package was installed. I guess nothing more can be done regardless this issue.

stecman commented 8 years ago

As much as I'd like to remove bash-completion as a dependency, the alternatives are either:

  1. provide a implementation with this library to handle : in completion results, or
  2. allow completion to run without colon support when those functions aren't defined (or provide a developer option to disable it)

I'd rather not provide an extract/"polyfill" of bash-completion with this library to support the required functions, since that would need to be kept up to date with the upstream repository. Allowing completion to run without colon support also isn't a great solution, since it makes the behaviour less predictable, even though some programs may not even use colons in their completion results. Adding an option to disable the requirement of bash-completion functions doesn't seem like a terrible idea, but it does add complexity for an edge case.

The authors of the bash-completion project have done an excellent job of working around BASH's treatment of word break characters in completion results over the last decade, so there's really no better solution than to use their work. The required functions can be pulled out of bash-completion quite easily, so I'd recommend doing that if installing from a package manager or from source aren't feasible. I've pulled out the required functions in a gist as an example.

I'll leave this open for now, since the dependency on bash-completion isn't documented currently.

aik099 commented 8 years ago

In the #58 we've added checks to show nice message, when Bash Completion package isn't installed in OS.

stecman commented 7 years ago

I was going to add the following at the bottom of the readme, but on further thought this has only been raised once in 3.5 years - anyone experiencing this issue should be able to find this thread.

System requirements

When running completion in a BASH shell, this library requires that the bash-completion package is installed. bash-completion is installed in many distributions by default or can usually be installed from a distribution's package manager. If any form of installation is impossible for some reason, see issue #36 for a shim.

aik099 commented 7 years ago

There can't be too much documentation. Better to add it.